question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug with `encodeKey` and `encodeValue`

See original GitHub issue

encodeValue looks like this (https://github.com/lpinca/shopify-token/blob/master/index.js#L7-L29)

function encodeValue(input) {
  return input.replace(/&/g, '%26').replace(/%/g, '%25');
}

If input was '&', it would return '%2526' – the % from the first replace is replaced again in the 2nd one.

Is there a reason not to use use encodeURIComponent? Or perhaps,

input.replace(/[&%]/g, function(c) { return encodeURIComponent(c); })

?

Thanks

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jamiemtdwyercommented, Sep 8, 2016

Hey guys,

Jamie from Shopify here. I would recommend taking a look at the strategy used in our official OAuth gem for Ruby:

https://github.com/Shopify/omniauth-shopify-oauth2/blob/master/lib/omniauth/strategies/shopify.rb#L67

We replace &=% in keys and &% in values with their respective URI-encoded values.

Cheers!

Read more comments on GitHub >

github_iconTop Results From Across the Web

[BUG] TypeScript Angular Escape colon · Issue #3372 - GitHub
[BUG] TypeScript Angular Escape colon #3372 ... Bug Report Checklist ... encodeKey(k); return k.replace(/\+/gi, '%2B'); } encodeValue(v: string): string { v ...
Read more >
Angular url plus sign converting to space - Stack Overflow
This ia a common problem. The + character is used by the URL to separate two words. In order to use the +...
Read more >
Comment #5 : Bug #945176 : Bugs : txAWS - Launchpad Bugs
Comment 5 for bug 945176. Revision history for this message ... result.append("%s=%s" % (self.encode(key), self.encode(value)))
Read more >
Issue 8603: Create a bytes version of os.environ and getenvb()
A view comments on the patch: + def __init__(self, data, encodekey, decodekey, encodevalue, decodevalue, putenv, unsetenv): As general ...
Read more >
Angular Url Encode - StackBlitz
encodeValue (param);. } jsEncode(param: string){. return encodeURIComponent(param);. } ngDecode(param: string){. return this.codec.decodeValue(this.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found