How do you escape round brackets in passwords for bitbucket-api in node.js -


i trying access particular repository on bitbucket using bitbucket-api in node.js , password contains funny characters (round brackets , spaces). doesn't throw useful errors or let me data.

i happen password don't want change it. know removing round brackets , spaces password fixes issue.

what can do?

after plenty of searching , stepping implementation curl-transport.js, have found way work around issue. relies on understanding of curl-transport passes require('child_process').exec.

essentially mechanism works starting new process curl , passing in command line arguments. having round brackets, confuses curl , having spaces confuses command line argument parsing. work around it, simply add double quote first character of username , ending double quote last character of password; when 2 strings concatenated (ie: username+":"+password) final string "username:password" get's passed 1 argument process.

my node code looks this:

var bitbucket = require('bitbucket-api'); var credentials = { username: '"username', password: 'password spaces , ()s"' }; var client = bitbucket.createclient(credentials); var repository = client.getrepository({ slug: 'reponame', owner: 'username' }, function (err, repo) {     //code access repo object.     console.log(repo); }); 

notice how username has additional double quote @ beginning of value (this hack). have added spaces , emphasised below because it's not obvious::

  • username: ' " username'

notice how password has additional double quote @ end of value (this hack). have added spaces , emphasised below because it's not obvious:

  • password: 'password spaces , ()s " '

the call succeed , details repository.

btw, fix worked me in v0.0.6 of bitbucket-api on windows 8.


a helpful note:

on windows, please remember put following path can find curl. can through [win8: windows-x]->system->advanced system settings->advanced->system variables->path->edit...

make sure git's binaries in path curl:

c:\program files (x86)\git\bin 

also, if trying work on heroku might need work around pathing issues re-installing heroku toolbelt under c:\heroku (see other posts why) , adding following path:

c:\heroku\ruby-1.9.2\bin;c:\heroku\bin;c:\program files (x86)\git\bin 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -