1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Not a Bug {xen:jsescape Does not escape some characters

Discussion in 'Resolved Bug Reports' started by Chris D, Jun 14, 2012.

  1. Chris D

    Chris D XenForo Developer Staff Member

    I am working on an add-on which has some configurable options in the Admin CP which are then inserted into javascript using the following code:
    Code:
    {xen:jsescape {xen:raw $xenOptions.myAddOnFullText}}
    The default text of my text box contains this, for example.

    Code:
    <p>The default text of my text box contains HTML which is escaped properly but also doesn't escape apostrophes properly</p>
    The source of the page looks like this, for example.

    HTML:
    <script>fulltext: '<p>The default text of my text box contains HTML which is escaped properly but also doesn't escape apostrophes properly<\/p>'</script>
    So the apostrophe isn't escaped, breaking the javascript. In my mind, jsescape should escape the apostrophes properly like it does with the </p> tag.

    I am working around this at the moment to have the default text with words such as does not instead of doesn't.
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    That function defaults to escaping double quotes. Try this:

    Code:
    {xen:jsescape {xen:raw $xenOptions.myAddOnFullText}, single}
    
    For reference:

    XenForo_Template_Helper_Core::jsEscape
     
    MattW and Chris D like this.
  3. Chris D

    Chris D XenForo Developer Staff Member

    I will try it and let you know :)

    Just about to release the add-on though so I'll implement it in the next version if it works.
     
  4. Chris D

    Chris D XenForo Developer Staff Member

    I forgot to thank you for this - it works great. Cheers Jake.
     
  5. MattW

    MattW Well-Known Member

    Just what I was looking for (y)
     

Share This Page