ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Escaping Apostrophes?

January 24, 2011 6:28pm

Subscribe [3]
  • #1 / Jan 24, 2011 6:28pm

    bsrweb

    24 posts

    I’m getting a “Parse error: syntax error, unexpected T_STRING… Functions.php(650) : eval()‘d code on line 76” error message and I believe I’ve distilled the issue down to a bit of Javascript code from Google’s Analytics.

    Here’s the JS code snippet:
    onClick=”[removed] _gaq.push([‘_trackPageview’, ‘/downloads/{title}’);”

    And here’s the strange part:
    (1) I have a multilingual site
    (2) I have custom fields for displaying English and Chinese in all my Channels
    (3) I get no error message when using that JS snipped above in the English-language fields
    (4) Error message shows up when using that same JS snippet in a Chinese-language field or field with Chinese characters in them

    I’m thinking it’s the apostrophe in the JS that’s tripping the error message? Is there a way to escape them?

    Using EE 2.1.3 and the fields in question are EE stock textarea fields with formatting buttons turned on.

    Help?

  • #2 / Jan 25, 2011 3:58pm

    Ingmar

    29245 posts

    This only happens with Google Analytics? Do you’ve got a link to the site?

  • #3 / Jan 25, 2011 4:11pm

    bsrweb

    24 posts

    That’s a good question and I just tried this snippet using an apostrophe to inclose a class value and got the same error message:
    Apostrophe.

    When I removed this line, no error message.

    I don’t know if this is related but when Chinese characters are entered into custom fields, when I view the HTML source on the front-end, these fields convert the characters to numeric entities (I don’t have Convert HTML into character entities turned on).

    Is there any to disable this conversion? I wonder if that might make a difference?

    Oh, and there’s no public access to the site yet… still under development.

  • #4 / Jan 26, 2011 4:46am

    John Henry Donovan

    12339 posts

    bsrweb,

    Can you try single apostrophes as opposed to the curly ones. See below for the difference.

    <span class='caption'>Apostrophe</span>
    <span>Apostrophe</span>

    It may be just the way you copy and pasted into this forum but worth checking

    I don’t know if this is related but when Chinese characters are entered into custom fields, when I view the HTML source on the front-end, these fields convert the characters to numeric entities (I don’t have Convert HTML into character entities turned on).

    What formatting do you have set for the custom field?

  • #5 / Jan 26, 2011 3:37pm

    bsrweb

    24 posts

    Hi John,

    Thanks for the reply. No, they’re definitely apostrophes in the fields.

    When I looked back at the field settings, I have EE textarea fields set to “none” in terms of formatting. I tried the other 2 —
    and XHTML — but the results were the same.

    For what it’s worth, I misspoke earlier about the conversion of the characters into numeric entities — it’s actually Wygwam that’s doing this. Maybe I should try switching to a TinyMCE-based WYSIWYG?

  • #6 / Jan 27, 2011 8:55am

    John Henry Donovan

    12339 posts

    bsrweb,

    Wygwam uses CKEditor. In your Wygwam configuration you should find an entities option under advanced settings.
    We can’t support you other than that I’m afraid as its a third-party add-on. If you need to follow up please do so on the P&T forums.

    Hope that helps

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases