You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I'm trying to "unparse" an RQL expression - restore it to its textual form. To this end, I'm constructing a Query object seeded with the raw result of the parsing:
In the nominal case of no special chars, it works just fine - however, as presented above, an error will be thrown:
/home/thewanderer/Devel/Node/rql-test/node_modules/rql/parser.js:218
string = decodeURIComponent(string);
^
URIError: URI malformed
at decodeURIComponent (native)
at Object.exports.converters.auto (/home/thewanderer/Devel/Node/rql-test/node_modules/rql/parser.js:218:13)
at Object.exports.encodeValue (/home/thewanderer/Devel/Node/rql-test/node_modules/rql/query.js:82:43)
at queryToString (/home/thewanderer/Devel/Node/rql-test/node_modules/rql/query.js:66:18)
at serializeArgs (/home/thewanderer/Devel/Node/rql-test/node_modules/rql/query.js:43:16)
at queryToString (/home/thewanderer/Devel/Node/rql-test/node_modules/rql/query.js:62:7)
at serializeArgs (/home/thewanderer/Devel/Node/rql-test/node_modules/rql/query.js:43:16)
at Query.toString (/home/thewanderer/Devel/Node/rql-test/node_modules/rql/query.js:50:3)
at Object.<anonymous> (/home/thewanderer/Devel/Node/rql-test/rubbish.js:4:31)
This is probably because the Query object takes args verbatim and, during stringification, checks whether the "converted" form is the same as the input before deciding whether to apply a type prefix (turns something into string:something) . However, this uses the parser's converter, which, instead of encoding the contents, decodes it - the converter is one-way only. I consider this a logic bug.
The text was updated successfully, but these errors were encountered:
rkaw92
changed the title
Unparsing with special chars
.toString() with special chars throws
Aug 24, 2016
rkaw92
added a commit
to greatcare/rql
that referenced
this issue
Aug 24, 2016
This change enables converting values containing special characters, such as the percent sign (%), to strings, by always encoding values for which the check if encoding is actually necessary has failed.
For values containing URI escape characters, the check throws an error (because they are not decodable), but we still need to encode them.
Fixespersvr#75
Hi,
I'm trying to "unparse" an RQL expression - restore it to its textual form. To this end, I'm constructing a Query object seeded with the raw result of the parsing:
In the nominal case of no special chars, it works just fine - however, as presented above, an error will be thrown:
This is probably because the Query object takes args verbatim and, during stringification, checks whether the "converted" form is the same as the input before deciding whether to apply a type prefix (turns
something
intostring:something
) . However, this uses the parser's converter, which, instead of encoding the contents, decodes it - the converter is one-way only. I consider this a logic bug.The text was updated successfully, but these errors were encountered: