Re: [Phplib-users] Patch to page.inc
Brought to you by:
nhruby,
richardarcher
From: Marko K. <M.K...@os...> - 2002-10-31 09:09:15
|
Hi, > $HTTP_SERVER_VARS["QUERY_STRING"] = ereg_replace("([?&])" . > $this->urlaction . "=(.)*&*", "\\1", > $HTTP_SERVER_VARS["QUERY_STRING"]); Well, here I don't understand what is actually done. Looks like it searches for GET parameters (called urlaction) and tries to locate them in the GET string embraced by [?&] and [&]. But I cannot forsee what happens if there are more than one '&' for instance. Could be the (.)* construct would eat that as well. I'd expect at least stg like (.*) to get the full string, or even better ([^&]*) to avoid any ampersands in the param content. On the other hand I don't understand the \\1 parameter, since it would just return the ([?&]) character. \\2 wouldn't be used anyway. Looking at this is now it looks like it should simply remove the urlaction parameter from the QUERY_STRING. Is this true??? But then, look at this: ---snip--- ***script start*** <?php $a='url?test=testen&&test2=test2en&'; echo "Rewrote:".ereg_replace("([?&])test=(.)*&*", "\\1",$a)."\n"; ?> ***script end*** ***script output start*** X-Powered-By: PHP/4.1.1 Content-type: text/html Rewrote:url? ***script output end*** ---snip--- So everything is eaten by the RE, just "url?" ist left! Looks like this regexp does not what it should. Maybe I misunderstood something... What do you really want to do with this rewrite of the url, looks like I skipped that part of the discussion somehow, sorry? > $HTTP_SERVER_VARS["QUERY_STRING"] = ereg_replace("[&][&]+", "&", > $HTTP_SERVER_VARS["QUERY_STRING"]); The RE could be rewritten as "[&]{2,}" to delete only multiple ampersands. Marko |