We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27889
    • 415 Posts
    Hello, perhaps someone can answer me.

    I use friendly URL.
    the /index.php strip the ’:’ char from the url so:
    in system var $_SERVER[’HTTP_REFERER’]
    my $_SERVER variables contains strange chars:

    http://localhost:85/modx/recherche.html
    become:
    http//localhost85/modx/recherche.html
    I think the same problem occurs for these type of url:
    http//login:password@localhost85/modx/recherche.html

    The two char ’:’ and ’@’ must not be stripped from the url
    I changed the line 54 of /index.php from:
    $_SERVER[$outside] = isset($_SERVER[$outside]) ? preg_replace("/[^A-Za-z0-9_\-\,\.\/\s]/", "", $_SERVER[$outside]): '';

    to:
    $_SERVER[$outside] = isset($_SERVER[$outside]) ? preg_replace("/[^A-Za-z0-9_\-\,\:\@\.\/\s]/", "", $_SERVER[$outside]): ''; 

    And all is done.

    Anyone can confirm ?
    is this a bug ? or I missed something ?

    I post it in at http://modxcms.com/bugs/task/497
    someone can check this ?
      MODx Sites & Prestations: http://dp-site.fr [Last MODx Site]
      MODx Repository: [HOME] [MetaTagsExtra] / Current Dev: [xFDM]
      • 22303 MODX Staff
      • 10,725 Posts
      Thanks for catching and posting that one Soda. I’ll make sure that one gets taken care of ASAP, along with some similar issues in the same area of variable scrubbing.
        • 20765
        • 90 Posts
        myfriendscallmebill Reply #3, 20 years, 1 month ago
        I think I’ve encountered another variation on the same problem in using $_SERVER[’HTTP_REFERER’].

        The website I’m building is often called (by google, et al) with query strings. Our programmer has been trying to grab the variables from this string, starting by reading $_SERVER[’HTTP_REFERER’].

        But we find three anomalies: First, when the page is first invoked, $_SERVER[’HTTP_REFERER’] has no query string attached to the URL. Second, when we click a link that takes us to a second page within the website $_SERVER[’HTTP_REFERER’] contains the query string that was intended for the first page. Third, all the punctuation (particularly "&" and "=") have been stripped out, leaving the names and values all jammed together with no delimiters.

        We’re guessing that the following code which appears at the beginning of the main index.php file is causing this, but we don’t really know:

        // secure variables from outside
        // added 03-05-06
        foreach(array('HTTP_REFERER','HTTP_USER_AGENT') as $outside) {
          $_SERVER[$outside] = isset($_SERVER[$outside]) ? preg_replace("/[^A-Za-z0-9_\-\,\.\/\s]/", "", $_SERVER[$outside]): '';
          if(strlen($_SERVER[$outside])>255) $_SERVER[$outside] = substr(0,255,$_SERVER[$outside]);
        }
        if(isset($_GET['q'])) $_GET['q'] = preg_replace("/[^A-Za-z0-9_\-\.\/]/", "", $_GET['q']);
        
          • 27889
          • 415 Posts
          But we find three anomalies: First, when the page is first invoked, $_SERVER[’HTTP_REFERER’] has no query string attached to the URL.
          If you invoke the page directly by typing an url $_SERVER[’HTTP_REFERER’]is null, this is normal because there is no page you come from.
          Second, when we click a link that takes us to a second page within the website $_SERVER[’HTTP_REFERER’] contains the query string that was intended for the first page.
          I guess this is normal too, $_SERVER[’HTTP_REFERER’] contain the url of the page you are coming from, if you are in index.html and click a link to mypage.html, in mypage.html the $_SERVER[’HTTP_REFERER’] contains mypage.html.
          all the punctuation (particularly "&" and "=") have been stripped out, leaving the names and values all jammed together with no delimiters.
          If you want to check the variable use: $GET[’my_var_name’]
          Try this:
          The chars ’:’ and ’@’ ,’?’ ’&’ must not be stripped from the url
          I changed the line 54 of /index.php from:

          $_SERVER[$outside] = isset($_SERVER[$outside]) ? preg_replace("/[^A-Za-z0-9_\-\,\.\/\s]/", "", $_SERVER[$outside]): '';


          to:
          $_SERVER[$outside] = isset($_SERVER[$outside]) ? preg_replace("/[^A-Za-z0-9_\-\,\:\@\.\?\&\/\s]/", "", $_SERVER[$outside]): ''; 
          

            MODx Sites & Prestations: http://dp-site.fr [Last MODx Site]
            MODx Repository: [HOME] [MetaTagsExtra] / Current Dev: [xFDM]