From 410731203c04200436cd992d706b85efbbdb8f5e Mon Sep 17 00:00:00 2001 From: fisehara Date: Wed, 3 Jan 2024 16:15:36 +0100 Subject: [PATCH] Decode escaped URI Parser is not parsing for escaped characters like %27='(' or %28=')' Change-type: patch Signed-off-by: fisehara --- odata-parser.pegjs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/odata-parser.pegjs b/odata-parser.pegjs index 6e9b8d5..fa2de19 100644 --- a/odata-parser.pegjs +++ b/odata-parser.pegjs @@ -1,3 +1,15 @@ +{{ + function uriDecodeFn() { + if (typeof window !== 'undefined') { + return decodeURI + } else { + const querystring = require('node:querystring'); + return querystring.unescape + } + } + const uriDecode = uriDecodeFn(); +}} + { const methods = { cast: [ 1, 2 ], @@ -85,6 +97,7 @@ binds.push([type, value]) return { bind: binds.length - 1 } } + input = uriDecode(input) } Process = @@ -131,7 +144,6 @@ QueryOption = Dollar '$ query options' = '$' - / '%24' ParameterAliasOption = '@' name:Text '=' @@ -645,7 +657,6 @@ Text = Sign = '+' - / '%2B' { return '+' } / '-' / '' @@ -653,7 +664,6 @@ Sign = // TODO: This should really be done treating everything the same, but for now this hack should allow FF to work passably. Apostrophe = '\'' - / '%27' { return '\'' } QuotedText = @@ -718,6 +728,5 @@ spaces = space = ( ' ' - / '%20' / '+' ) \ No newline at end of file