dreamos82/chrome_parameters

[BUG] unescape() is deprecated

Closed this issue · 3 comments

bug

Unicode-encoded strings in params get mojibake.

code

text_input_element.setAttribute("value", unescape(parameter_array[1]));

fix

It would be a solution to fix this by using decodeURIComponent like this:

function decodeQueryParam(p) {
  return decodeURIComponent(p.replace(/\+/g, ' '));
}

decodeQueryParam('search+query');

ref

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/unescape

Usually, decodeURI or decodeURIComponent are preferred over unescape.

Note: Do not use unescape to decode URIs, use decodeURI instead.

Hi wintus,

thanks you for your bug and your suggestion, since you proposed already a solution, i htink it would be fair to you to open a PR and i will review and merge it in the coming days. But if you don't have time or don't want i'll test you suggested code and fix it in coupole of days.

Thanks again!

Sure, I'm gonna try to submit a PR on it in a upcoming week!

Thank you @Wintus