Pacharapol Withayasakpunt
Posted on July 14, 2020
Indeed, the MDN said that
var set1 = ";,/?:@&=+$"; // Reserved Characters
var set2 = "-_.!~*'()"; // Unescaped Characters
var set3 = "#"; // Number Sign
var set4 = "ABC abc 123"; // Alphanumeric Characters + Space
console.log(encodeURI(set1)); // ;,/?:@&=+$
console.log(encodeURI(set2)); // -_.!~*'()
console.log(encodeURI(set3)); // #
console.log(encodeURI(set4)); // ABC%20abc%20123 (the space gets encoded as %20)
console.log(encodeURIComponent(set1)); // %3B%2C%2F%3F%3A%40%26%3D%2B%24
console.log(encodeURIComponent(set2)); // -_.!~*'()
console.log(encodeURIComponent(set3)); // %23
console.log(encodeURIComponent(set4)); // ABC%20abc%20123 (the space gets encoded as %20)
But in specific situations (path params, querystring, hash), do these need to be encoded?
-
;,:+$
in general? -
=
and possbly;,/?:+$
inside querystring values? -
#
inside hash? - Are non-ASCII character sets potentially dangerous?
๐ ๐ช ๐
๐ฉ
Pacharapol Withayasakpunt
Posted on July 14, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
webdev I want to participate in a web application project. Could you give me some ideas?
November 27, 2024
python Building Maintainable Python Applications with Hexagonal Architecture and Domain-Driven Design
November 26, 2024