Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

106
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda