[Xitami] LRWP, CGI and HTTP_REFERER

Paul Osze paul_osze at comcast.net
Mon Jun 26 01:49:23 CEST 2006


Okay, looks like I answered my own question.

Xitami does not pass the query string portion of http-referer by design.

 From smt/smthttpl.c:

            /*  It's possible that the Referer: field contains an URL
             *  followed by ? and a whole long argument...  We don't want
             *  that stuff.  Get rid of it.  (But save it all first.)
             */
            if (streq (header_name, "referer")) {
                mem_strfree (&p_http-> referrer);
                p_http-> referrer = mem_strdup (header_value);
                if (strchr (header_value, '?') != NULL)
                    *strchr (header_value, '?') = '\0';
            }

To fix this, I just commented out the stripping statement and recompiled:

            /*  It's possible that the Referer: field contains an URL
             *  followed by ? and a whole long argument...  We don't want
             *  that stuff.  Get rid of it.  (But save it all first.)
             */
            if (streq (header_name, "referer")) {
                mem_strfree (&p_http-> referrer);
                p_http-> referrer = mem_strdup (header_value);
               /*
                if (strchr (header_value, '?') != NULL)
                    *strchr (header_value, '?') = '\0';
               */
            }

Do this, and you'll be able to get the full HTTP-REFERER url in CGI, 
PHP, LRWP, etc.

Hope this helps anyone else who's been stumped by this.



More information about the Xitami mailing list