Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

102
Views
How do I decode characters from strings in polymer data binding?

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

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!