views:

71

answers:

3

Hey,

Does \h have some special meaning? I store the username in a hidden field in my HTML, and all usernames works, but mine (which is DOMAIN\hers....) fails, it ends up like "DOMAINhers...) when picked up by Javascript (JQuery).

Any ideas?

+5  A: 

When storing strings in JavaScript you should allways escape the \ character, by replacing "\" with "\\". Just image when someone has the username "DOMAIN\noel". That will end up like

DOMAIN
oel
Espo
A: 

\h isn't an escape character in Javascript.

Greg
but "\" is... ;)
Robert Koritnik
Yes of course...
Greg
A: 

There is no special meaning for "\h", but the backslash will still be escaped. You'll have to escape the backslash itself for your username to work so that you have "DOMAIN\hers....".

Eifion