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.

Ampersand in path global variable adda a semi-colon

February 23, 2008 8:35am

Subscribe [3]
  • #1 / Feb 23, 2008 8:35am

    Jamie Pittock

    108 posts

    Greetings.

    I’m doing the following in my path.php file:

    $global_vars = array(
        "inclusive_stack" => "4&5;"
        );

    When I display the variable in my template it has a semi-colon on the end, 4&5;

    It’s got something to do with the ampersand and the global_vars array.

    Any ideas?

  • #2 / Feb 23, 2008 8:36am

    Jamie Pittock

    108 posts

    It’s even doing it in the code above.  Let’s try it using & amp; instead and with no code highlighting…

    $global_vars = array(
      “inclusive_stack” => “4&5”
      );

  • #3 / Feb 23, 2008 9:35am

    Simon Clayson

    38 posts

    & #38;

    ?

  • #4 / Feb 23, 2008 9:45am

    Jamie Pittock

    108 posts

    Hello mate.

    Nope that wouldn’t work because I’m using the path variable as a parameter value in the weblog:entries tag -  category=”{path_variable}”

    It needs to be an ampersand rather than the HTML entity.  Just got to figure why a semi-colon is being added.

    Saturday afternoon fun!

  • #5 / Feb 23, 2008 9:50am

    Simon Clayson

    38 posts

    Is the semi colon the result of EE wanting to build the 5 into a character entity?

    What if you used “five” instead of “5” what happens then?

  • #6 / Feb 23, 2008 9:57am

    Jamie Pittock

    108 posts

    It displays 4&five;

  • #7 / Feb 23, 2008 9:59am

    Low

    407 posts

    I think EE thinks anything with a & is considered an html-entity, and should be closed with a semicolon. I’ll take a look-see.

  • #8 / Feb 23, 2008 10:02am

    Simon Clayson

    38 posts

    It’s gone beyond me I’m afraid…

  • #9 / Feb 23, 2008 10:07am

    Low

    407 posts

    Yup, the xss_clean() function that sanitizes all input data and keeps it safe will add the semicolon (line 614 in core.regex.php):

    /*
    * Validate standard character entities
    *
    * Add a semicolon if missing.  We do this to enable
    * the conversion of entities to ASCII later.
    *
    */
    $str = preg_replace('#(&\#?[0-9a-z]+)[\x00-\x20]*;?#i', "\\1;", $str);

    Guess that in this case, you’d have to create an extension to set the variable you want.

  • #10 / Feb 23, 2008 11:02am

    Jamie Pittock

    108 posts

    Thanks all.

  • #11 / Feb 24, 2008 11:07am

    Robin Sowell

    13255 posts

    Yep- Lodewijk nailed it.  It’s a known issue- a result of some security measures.  Since it comes up rarely and can usually be resolved by using the entity instead, (and the fix adds a lot of extra load to the parsing engine) it’s lingered a bit.  But the crew is a aware of it and keeping an eye on it for 2.0.

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

ExpressionEngine News!

#eecms, #events, #releases