• Resolved mmdl

    (@mmdl)


    Hello,

    I have repeatedly tried inserting a piece of Javascript in an article. This script contains a call to a function with arguments, enclosed in quotes.

    This does not work: upon looking at the source of the resulting page, I see that the quotes (single or double) are converted to HTML entities (’ and ”). Sometimes, this happens to just the first argument, while the second one has the correct quotes, sometimes to all. I haven’t been able to determine what the logic is, bur regardless, at least the first pair of quotes is thus changed, and the script fails.

    If I put this very same call into an image onLoad attribute, no argument is changed (but I can’t leave it that way, due to the logic of the script: it has to be outside the image).

    This transformation of the quotes occurs when the page is loaded for display. The code in the underlying database is correct.

    Searching back in the bugs, I have seen something similar reported at least twice, but with no solution provided. Any help, please?

    Thanks.

    PS: I think it may have something to do with parentheses: in the paragraph above, the two entity codes provided in parentheses were treated differently when in backticks around the whole parenthetical comment: the first had its pound sign removed.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter mmdl

    (@mmdl)

    More info.
    Here is a blantantly odd way in which WordPress breaks the code – not only by replacing the quotes with the entities, but in an unbalanced fashion:

    – What I wrote:
    <script ...>myFunction('arg1','arg2','arg3',arg4)
    (the last one is a numeric value)

    – Here is the code in the resulting Web page:
    <script ...>myFunction(&#8217;arg1&#8217;,'arg2&#8217;,'arg3&#8217;,arg4)
    (i.e., the first quote of the second and the third argument are left unchanged – which is correct, all the other ones are broken).

    Thread Starter mmdl

    (@mmdl)

    The problem is with the logic of wptexturize; when I bypass its (flawed) logic by inserting, as first argument, a return($text), the problem disappears.

    Thread Starter mmdl

    (@mmdl)

    I found the bug in the code, it is quite difficult to locate.

    The parentheses around the arguments to the 5 calls to the strstr() function on line 41 don’t balance: a closing one is missing after one of the calls and was added to balance at the end of the clause. No wonder it didn’t work.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Quotes in scripts are converted to entities’ is closed to new replies.