I have a script that is rendered to an html page as a part of a tracking solution (etracker).
It is something like this:
<script>
var et_cart= 'nice shoes,10.0,100045;nice jacket,20.00,29887';
</script>
This will be transmitted to the server of the tracking solution by some javascript that I don't control. It will end up as 2 items. The items are separated by a semicolon in the source (after '100045').
I obviously need to Html-encode and Javascript-encode the values that will be rendered. I first Html-encode and after that remove single quotes.
This works, but I have an issue with special characters in french and german e.g. umlaut (ü, ä...). They render something like {. The output of the script when using lars ümlaut as the article is:
<script>
var et_cart= 'lars {mlaut,10.0,100045;nice jacket,20.00,29887';
</script>
The semicolon is evaluated as an item separator by the tracking solution.
The support of the tracking solution told me to url-encode the values. Can this work? I guess URL-encoding doesn't stop any xss-atacks. Is it ok to first url-encode and html-encode, then javascript-encode after it?