Skip to content

Detect and modify invalid URL characters#1664

Merged
this-is-shivamsingh merged 12 commits intomasterfrom
PPLT_3177
Jul 24, 2024
Merged

Detect and modify invalid URL characters#1664
this-is-shivamsingh merged 12 commits intomasterfrom
PPLT_3177

Conversation

@this-is-shivamsingh
Copy link
Copy Markdown
Contributor

@this-is-shivamsingh this-is-shivamsingh commented Jul 18, 2024

Jira: https://browserstack.atlassian.net/browse/PPLT-3177
Issues:

  • When the snapshot URL contains invalid characters that are not supported as a part of valid URI syntax, it causes the renderer to break due to strict checking of URLs.
  • These invalid URLs result in either parsing issues OR invalid responses like 404/ 307(redirect to with corrected URL) by browsers, which can cause resources not to get loaded in time or bad URI errors.
  • Mostly this causes Renderer Timeout as per some previously reported issues by users.

Changes:

  1. Encoding url using encodeURI, this encodes the invalid/unsupported characters with their respective encoding characters.
    Eg:
<space> -> %20
[ -> %5B
] -> %5D and so on.
  1. In case the URL is partially encoded by the user, we first decode it and then encode it, so that the already encoded character should not get encoded again, doing decodeURI first makes the URL to come in original form and then encodeURI, converts every unsupported character to there respective encoded character. This avoids encoding of already encoded characters.
  2. If the URL is valid, then decoding will not affect anything, it only decodes the already encoded character to the original character. Eg. /abc -> /abc, %20 -> <space>, %5B -> [ and so on.

Testing:

  1. Run builds with different types of valid and invalid URLs to verify where it break.
  2. Test with url’s containing # $ % !, * <space> [ ] {} etc, that are generally unsupported by browsers.

@this-is-shivamsingh this-is-shivamsingh requested a review from a team as a code owner July 18, 2024 19:41
@this-is-shivamsingh this-is-shivamsingh changed the title feat: added invalid URL detection for snapshot & network urls Detect and modify invalid URL characters Jul 18, 2024
@this-is-shivamsingh this-is-shivamsingh merged commit a555427 into master Jul 24, 2024
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

Successfully merging this pull request may close these issues.

3 participants