Skip to content
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

Percentage symbol in query string breaks in SSR #171

Closed
AnthonySmithVT opened this issue Apr 3, 2019 · 2 comments
Closed

Percentage symbol in query string breaks in SSR #171

AnthonySmithVT opened this issue Apr 3, 2019 · 2 comments
Assignees

Comments

@AnthonySmithVT
Copy link

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

  1. Use the headless SSR via sitecore-jss-proxy
  2. Navigate to any page
  3. Add a query string of ?s=% or ?s=%25 to the url and press enter
  4. 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.

Your Environment

  • Sitecore Version: Sitecore.NET 9.1.0 (rev. 001564)
  • JSS Version: 11.0
  • Browser Name and version: Google Chrome Version 73.0.3683.86 (Official Build) (64-bit)
  • Operating System and version (desktop or mobile): Windows 10

Screenshots

image

@sc-illiakovalenko
Copy link
Contributor

sc-illiakovalenko commented Jul 8, 2020

@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=%

@sc-illiakovalenko
Copy link
Contributor

@AnthonySmithVT Fixed in #400
In case if you will have any issues, feel free to reopen ticket or create another one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants