[wp-trac] [WordPress Trac] #37877: Conversion of quotation marks in wp_add_inline_script() results in invalid JavaScript

WordPress Trac noreply at wordpress.org
Sat Sep 17 12:02:03 UTC 2016


#37877: Conversion of quotation marks in wp_add_inline_script() results in invalid
JavaScript
-------------------------------+------------------------------
 Reporter:  dboulet            |       Owner:  swissspidy
     Type:  defect (bug)       |      Status:  assigned
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  General            |     Version:  4.5
 Severity:  normal             |  Resolution:
 Keywords:  reporter-feedback  |     Focuses:
-------------------------------+------------------------------
Changes (by swissspidy):

 * keywords:   => reporter-feedback


Comment:

 > A string containing JavaScript which is passed to wp_add_inline_script()
 is sometimes rendered invalid when strings within it contain quotation
 marks.

 I cannot seem to reproduce this. See attached test in
 [attachment:37877.diff]. The output is `<script
 type='text/javascript'>"Aujourd'hui";</script>` as expected.

 Can you give us some more info? Does the test work on your system?

 > Interestingly, reversing the quotation marks results in the same output:

 The quotation marks you use for the string are irrelevant. PHP will only
 see what's inside, i.e. `'Aujourd\"hui';` in your second example.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/37877#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list