Problem:
I am currently working with polymer data binding and I have an apostrophe character that is showing up as \x27 on the client side. On the server side I'm sending back the data with owasp's java encoder: Encode.forJavaScript(string)
Code: (I've simplified it for the the sake of brevity.)
<dom-module id="x-custom">
<template>
My name is <span>[[_decodeName(personData.NAME)]]</span>
</template>
<script>
Polymer({
is: 'x-custom',
properties: {
personData: Object
},
ajaxLoaded: function(data) {
// I've also tried putting the decodeName logic here and acting directly on this.personData.NAME
},
_decodeName: function(name) {
return name.replace(new RegExp(String.fromCharCode(92)+"x27", "g"), "'");
}
...
});
</script>
</dom-module>
What I've tried:
I've tried computed data binding by writing a function that would replace this. That function has had several different implementations. I've also tried directly putting the logic of that function in the ajaxLoaded function which I believe gets called after all the data is returned from the server? As far as the logic of the _decodeName() function, I've tried using various different methods of replace and replaceAll and I've also tried decodeURIComponent(). The frontend name which includes an apostrophe is still showing up as \x27
Expected Output:
I'd like the output on the front end to display as an apostrophe character and not \x27