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

Wrong usage of JS functions (Appendix: Leveraging Dev Tools - Encoding and Decoding) #1070

Closed
ukusormus opened this issue Jun 22, 2023 · 1 comment · Fixed by #1085
Closed
Labels
revise Needs quality review, updates, or revision
Milestone

Comments

@ukusormus
Copy link

What's the issue?

In Appendix: Leveraging Dev Tools > Encoding and Decoding:

  • Suggesting use of escape() and unescape() JavaScript functions for HTML encoding/decoding, while:

    • these functions do not actually encode/decode HTML in the traditional sense (HTML entities). Actual behavior:
    > escape("<script>")
    '%3Cscript%3E'
    
  • Suggesting use of encodeURIComponent() and decodeURIComponent for URL encoding/decoding, while:

    • these functions are meant to encode/decode URL parameter values, not full URLs, e.g.:
    > encodeURIComponent("https://www.example.com/?key=valuew/slash")
    'https%3A%2F%2Fwww.example.com%2F%3Fkey%3Dvaluew%2Fslash'
    

How do we solve it?

@ukusormus ukusormus added help wanted revise Needs quality review, updates, or revision labels Jun 22, 2023
@kingthorin
Copy link
Collaborator

kingthorin commented Jun 22, 2023

Thanks @ukusormus, feel up for tackling the change(s)?

How do we solve it?
Remove current form of HTML encoding/decoding. Maybe look for a better JavaScript solution or omit it entirely?

Let's omit it.

Rename the usage of URL encode/decode to reflect that they're meant for URL parameter values, and/or add encodeURI() also. See more: When are you supposed to use escape instead of encodeURI / encodeURIComponent? - an answer on Stack Overflow

Clarify what it's meant for, and add encodeURI().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
revise Needs quality review, updates, or revision
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants