Skip to content

Commit

Permalink
Fixded bug in pasring session data from url, now correctly code is aw…
Browse files Browse the repository at this point in the history
…are of 2 alphanum char aftyher % sign as percent encoded char
  • Loading branch information
gits2501 committed May 9, 2018
1 parent 37c4d2b commit a40aaa7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
language: node_js
node_js:
- '8.6.0'
- '9.11.1'
git:
depth: 3
before_install:
Expand Down
9 changes: 4 additions & 5 deletions src/AccessToken.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var deliverData = require('twiz-client-redirect').prototype.deliverData;

this.redirectionUrlParsed = true; // indicate that the url was already parsed

// console.log(this.redirectionData.twiz_);
// console.log('redirectionData: >>', this.redirectionData);
}

AccessToken.prototype.parse = function(str, delimiter1, delimiter2){ // parses substring of a string (str)
Expand Down Expand Up @@ -104,11 +104,10 @@ var deliverData = require('twiz-client-redirect').prototype.deliverData;

AccessToken.prototype.authorize = function(sent){ // check that sent data from redirection url has needed info

// console.log('in authorize');
if(this.isRequestTokenUsed(window.localStorage))
throw this.CustomError('noRepeat');


// console.log('in authorize')
if(!sent.oauth_verifier) throw this.CustomError('verifierNotFound');
if(!sent.oauth_token) throw this.CustomError('tokenNotFound');

Expand Down Expand Up @@ -141,7 +140,7 @@ var deliverData = require('twiz-client-redirect').prototype.deliverData;
storage.requestToken_ = null; // since we've loaded the token, mark it as
// used/erased with null
// console.log('after erasing storage.requestToken :', storage.requestToken_);

// console.log('loadedRequestToken',this.loadedRequestToken);
if (!this.loadedRequestToken) throw this.CustomError('requestTokenNotSet');
}

Expand All @@ -161,7 +160,7 @@ var deliverData = require('twiz-client-redirect').prototype.deliverData;
}

AccessToken.prototype.parseSessionData = function(str){
if(/%[0-9][0-9]/g.test(str)) // See if there are percent encoded chars
if(/%[0-9A-Z][0-9A-Z]/g.test(str)) // See if there are percent encoded chars
str = decodeURIComponent(decodeURIComponent(str)); // Decoding twice, since it was encoded twice
// (by OAuth 1.0a specification). See genSBS function.
return this.parseQueryParams(str); // Making an object from parsed key/values.
Expand Down

0 comments on commit a40aaa7

Please sign in to comment.