Commit 3691704b authored by Franz X Antesberger's avatar Franz X Antesberger

Merge pull request #9 from RubenVerborgh/percentencoding

Correctly encode percent signs in URIs
parents 21505bd8 47ba089e
...@@ -9,14 +9,9 @@ var LiteralExpression = (function () { ...@@ -9,14 +9,9 @@ var LiteralExpression = (function () {
index, index,
chr = ''; chr = '';
for (index = 0; index < literal.length; index += chr.length) { for (index = 0; index < literal.length; index += chr.length) {
chr = pctEncoder.pctCharAt(literal, index); chr = literal.charAt(index);
if (chr.length > 0) {
result += chr;
}
else {
result += rfcCharHelper.isReserved(chr) || rfcCharHelper.isUnreserved(chr) ? chr : pctEncoder.encodeCharacter(chr); result += rfcCharHelper.isReserved(chr) || rfcCharHelper.isUnreserved(chr) ? chr : pctEncoder.encodeCharacter(chr);
} }
}
return result; return result;
} }
......
...@@ -15,14 +15,9 @@ var encodingHelper = (function () { ...@@ -15,14 +15,9 @@ var encodingHelper = (function () {
text = text.toString(); text = text.toString();
} }
for (index = 0; index < text.length; index += chr.length) { for (index = 0; index < text.length; index += chr.length) {
chr = pctEncoder.pctCharAt(text, index); chr = text.charAt(index);
if (chr.length > 1) {
result += chr;
}
else {
result += rfcCharHelper.isUnreserved(chr) || (passReserved && rfcCharHelper.isReserved(chr)) ? chr : pctEncoder.encodeCharacter(chr); result += rfcCharHelper.isUnreserved(chr) || (passReserved && rfcCharHelper.isReserved(chr)) ? chr : pctEncoder.encodeCharacter(chr);
} }
}
return result; return result;
} }
......
...@@ -23,12 +23,13 @@ var rfcCharHelper = (function () { ...@@ -23,12 +23,13 @@ var rfcCharHelper = (function () {
/** /**
* Returns if chr is an reserved character according 1.5 of rfc 6570 * Returns if chr is an reserved character according 1.5 of rfc 6570
* or the percent character mentioned in 3.2.1.
* @param chr * @param chr
* @return {Boolean} * @return {Boolean}
*/ */
function isReserved(chr) { function isReserved(chr) {
return chr === ':' || chr === '/' || chr === '?' || chr === '#' || chr === '[' || chr === ']' || chr === '@' || chr === '!' || chr === '$' || chr === '&' || chr === '(' || return chr === ':' || chr === '/' || chr === '?' || chr === '#' || chr === '[' || chr === ']' || chr === '@' || chr === '!' || chr === '$' || chr === '&' || chr === '(' ||
chr === ')' || chr === '*' || chr === '+' || chr === ',' || chr === ';' || chr === '=' || chr === "'"; chr === ')' || chr === '*' || chr === '+' || chr === ',' || chr === ';' || chr === '=' || chr === "'" || chr === '%';
} }
return { return {
......
Subproject commit 6aad87eb6f7763e9806b9345dd90e697be6b1bbf Subproject commit b317372c613f1aab82f1e497146b2859144b9308
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment