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

encodeURI() incorrectly encodes newline characters #336

Closed
gadenbuie opened this issue Apr 13, 2022 · 1 comment · Fixed by #337
Closed

encodeURI() incorrectly encodes newline characters #336

gadenbuie opened this issue Apr 13, 2022 · 1 comment · Fixed by #337

Comments

@gadenbuie
Copy link
Member

From the encodeURI page on MDN, we expect "\n" to be encoded as "%0A", but httpuv::encodeURI() returns the wrong value.

httpuv::encodeURI("\n")
#> [1] "% A"

charToRaw(httpuv::encodeURIComponent("\n"))
#> [1] 25 20 41

charToRaw("%0A")
#> [1] 25 30 41

v8 <- V8::new_context()
v8$eval("decodeURI('%0A')")
#> [1] "\n"

Oddly, using V8 to evaluate encodeUIR("\n") results in an unspecified c++ exception

v8$eval("encodeURI('\n')")
#> Error in context_eval(join(src), private$context, serialize) : 
#>   c++ exception (unknown reason)
@wch
Copy link
Collaborator

wch commented Apr 14, 2022

It looks like it's putting a leading space instead of a 0.

httpuv::encodeURI("\n")
#> [1] "% A"
httpuv::encodeURI("\r")
#> [1] "% D"
httpuv::encodeURI("\f")
#> [1] "% C"

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 a pull request may close this issue.

2 participants