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

jsEncode is losing encoded characters in string. #207

Closed
unscriptable opened this issue Aug 12, 2013 · 5 comments
Closed

jsEncode is losing encoded characters in string. #207

unscriptable opened this issue Aug 12, 2013 · 5 comments

Comments

@unscriptable
Copy link
Member

See this discussion: https://groups.google.com/d/msg/cujojs/Gt1Fof6tjOk/i5856nGUDWsJ

@gehan
Copy link
Contributor

gehan commented Aug 12, 2013

e.g. these string evaluate to the same when they are different

jsEncode('content: "\e738"')

"content: "e738""

jsEncode('content: "e738"')

"content: "e738""

@unscriptable
Copy link
Member Author

Did a bit of research / testing. It seems that js converts all backslash-escaped characters it doesn't recognize to unescaped values:

> '\e738'.charCodeAt(0)
101

How could this possibly work in the original module(s)? Doesn't the js engine convert '\e738' to 'e738'?

-- J

@gehan
Copy link
Contributor

gehan commented Aug 13, 2013

Ah yes but the example I gave was a css file! I guess you need to make a
cssEncode function with different encoding logic.
On 13 Aug 2013 00:42, "John Hann" notifications@github.com wrote:

Did a bit of research / testing. It seems that js converts all
backslash-escaped characters it doesn't recognize to unescaped values:

'\e738'.charCodeAt(0)101

How could this possibly work in the original module(s)? Doesn't the js
engine convert '\e738' to 'e738'?

-- J


Reply to this email directly or view it on GitHubhttps://github.com//issues/207#issuecomment-22534110
.

@gehan
Copy link
Contributor

gehan commented Aug 13, 2013

http://www.merttol.com/articles/code/introduction-to-css-escape-sequences.html

On 13 August 2013 07:40, Gehan Gonsalkorale gehan.g@gmail.com wrote:

Ah yes but the example I gave was a css file! I guess you need to make a
cssEncode function with different encoding logic.
On 13 Aug 2013 00:42, "John Hann" notifications@github.com wrote:

Did a bit of research / testing. It seems that js converts all
backslash-escaped characters it doesn't recognize to unescaped values:

'\e738'.charCodeAt(0)101

How could this possibly work in the original module(s)? Doesn't the js
engine convert '\e738' to 'e738'?

-- J


Reply to this email directly or view it on GitHubhttps://github.com//issues/207#issuecomment-22534110
.

@gehan
Copy link
Contributor

gehan commented Aug 13, 2013

Here you go! \ is an escape character in JS so just need to handle that properly I think

#209

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