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
The sitecore-jss-proxy breaks when the Url contains a %. The error caused is "URIError: Uri Malformed".
This is happens in sitecore-jss-proxy/src/index.ts and is caused by calling decodeURIComponent(), as the url is not encoded as expected.
These calls are made in rewriteRequestPath() and isUrlIgnored().
This can also happen when %25 is included in the query string as the url is decoded twice, the first will decode this to %, the second will error.
We are using this query string to perform a search.
Expected behavior
The page should load without error, encoding the url if necessary.
Steps To Reproduce
Use the headless SSR via sitecore-jss-proxy
Navigate to any page
Add a query string of ?s=% or ?s=%25 to the url and press enter
The error should appear
Possible Fix
Add a try catch around the call to decodeURIComponent() in rewriteRequestPath().
Pass the unencoded path into isUrlIgnored() from rewriteRequestPath(), this will prevent it breaking when it tries to decode the url twice.
@AnthonySmithVT Are you sure about case using: ?s=% ?
Because by default it should be encoded - and you will get ?s=%25
So decodeURIComponent will always throw error in case with ?s=%
Description
The sitecore-jss-proxy breaks when the Url contains a %. The error caused is "URIError: Uri Malformed".
This is happens in sitecore-jss-proxy/src/index.ts and is caused by calling decodeURIComponent(), as the url is not encoded as expected.
These calls are made in rewriteRequestPath() and isUrlIgnored().
This can also happen when %25 is included in the query string as the url is decoded twice, the first will decode this to %, the second will error.
We are using this query string to perform a search.
Expected behavior
The page should load without error, encoding the url if necessary.
Steps To Reproduce
Possible Fix
Add a try catch around the call to decodeURIComponent() in rewriteRequestPath().
Pass the unencoded path into isUrlIgnored() from rewriteRequestPath(), this will prevent it breaking when it tries to decode the url twice.
Your Environment
Screenshots
The text was updated successfully, but these errors were encountered: