-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fisehara/decode uri before parsing #77
Conversation
4107312
to
3143f0c
Compare
7973d74
to
b08feb7
Compare
b08feb7
to
86af243
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm but I would prefer Page to make the call since I'm not familiar w/ this codebase.
The only weird case I could think was whether it's fine to decode the url part before the ?
.
38816c1
to
721f272
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still want to be confident that the changed parsing matches what the odata spec expects, but at least with the change as-is there's a bunch of pegjs level stuff to improve
@@ -641,19 +642,17 @@ DurationNumber = | |||
Text = | |||
// This regex is equivalent to `(!ReservedUriComponent)` | |||
text:$[^:/?#\[\]@!$*&()+,;=]* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
text:$[^:/?#\[\]@!$*&()+,;=]* | |
$[^:/?#\[\]@!$*&()+,;=]* |
odata-parser.pegjs
Outdated
@@ -551,7 +552,7 @@ SubPathSegment = | |||
ResourceName = | |||
// This regex is equivalent to `!(ReservedUriComponent / [ %])` | |||
resourceName:$[^:/?#\[\]@!$*&()+,;= %]+ | |||
{ return decodeURIComponent(resourceName) } | |||
{ return resourceName } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ return resourceName } |
@@ -551,7 +552,7 @@ SubPathSegment = | |||
ResourceName = | |||
// This regex is equivalent to `!(ReservedUriComponent / [ %])` | |||
resourceName:$[^:/?#\[\]@!$*&()+,;= %]+ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resourceName:$[^:/?#\[\]@!$*&()+,;= %]+ | |
$[^:/?#\[\]@!$*&()+,;= %]+ |
|
||
Sign = | ||
'+' | ||
/ '%2B' | ||
{ return '+' } | ||
/ '-' | ||
/ '' | ||
|
||
// TODO: This should really be done treating everything the same, but for now this hack should allow FF to work passably. | ||
Apostrophe = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be in-lined now that it only checks a single character and there (probably?) won't be any benefit from memoizing, and definitely no benefit from deduplicating
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment still stands
Parser is not parsing for escaped characters like %27='(' or %28=')' Change-type: patch Signed-off-by: fisehara <harald@balena.io>
5b7895c
to
6f762e8
Compare
@Page-
Given this syntax: odata-parser/odata-parser.pegjs Lines 116 to 133 in 6f762e8
The QueryOption should first split into QueryName and QueryValue and percent-decode both before parsing the data specific queryValue. |
odata-parser.pegjs
Outdated
) | ||
|
||
spaces = | ||
space* | ||
[\ +]* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no need to escape
?
[\ +]* | |
[ +]* |
odata-parser.pegjs
Outdated
@@ -583,7 +583,7 @@ Duration = | |||
'duration' | |||
Apostrophe | |||
// Sign must appear first if it appears | |||
sign:Sign | |||
sign:$[+\-]? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fwiw the -
doesn't actually need to be escaped if it's the first or last character in the character class
odata-parser.pegjs
Outdated
@@ -132,7 +134,6 @@ QueryOption = | |||
|
|||
Dollar '$ query options' = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this only checks a single character it makes sense to in-line imo
|
||
Sign = | ||
'+' | ||
/ '%2B' | ||
{ return '+' } | ||
/ '-' | ||
/ '' | ||
|
||
// TODO: This should really be done treating everything the same, but for now this hack should allow FF to work passably. | ||
Apostrophe = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment still stands
odata-parser.pegjs
Outdated
|
||
space = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fwiw I don't mind leaving this as an alias to avoid issues where in future people may add an extra thing that wants to check for spaces but don't realize that in a url a +
can be equivalent to a space and so only check ' '
instead of [ +]
. Unless of course there's a significant performance benefit
Yeah, I think we should match what the OData spec expects @fisehara because the better we match the more tooling/documentation/etc will be cross compatible |
Signed-off-by: fisehara <harald@balena.io>
Signed-off-by: fisehara <harald@balena.io>
6f762e8
to
cdc901d
Compare
Pre-percent decoding will violate OData parsing, case:
As of know this module is the most loaded module in pinejs stack and an OData / percent-encoded parity change would increase the load by >= 10% which is not desirable. |
Pull request was closed
No description provided.