Re: url_scanner.re

From: Date: Tue, 28 Mar 2000 15:37:09 +0000
Subject: Re: url_scanner.re
References: 1 2  Groups: php.version4 
Request: Send a blank email to php-version4+get-12772@lists.php.net to get a copy of this message
On Tue, Mar 28, 2000 at 03:53:31PM +0200, Sascha Schumann wrote: > > i'm trying to fix a bug i reported two weeks ago. (Bug ID #3848) > > I was able to track it down to url_scanner.re, but i am unable to fix > > it. I don't know what re2c is and where to get it (and the > > documentation). > > > > What i basicly wanted to change is around line 165: > > > > 162 /*!re2c > > 163 ["]? ws* (all\[> \t\v\f":#])* ws* ["]? { BEGIN(INITIAL); } > > 164 ["]? ws* (all\[> \t\v\f":#])* /[#] { BEGIN(INITIAL); } > > 165 ["]? ws* (all\[> \t\v\f"#])* ws* ["]? { > > 166 /* don't modify absolute links */ > > 167 state->state = INITIAL; BEGIN(INITIAL); > > I wanted to add an expression so that empty links (<A HREF=""> for > > example) do not get modified. > Can you point me to any standard which says that empty href elements are > not considered a link? Not directly. However you get problems if you make a construct such as <a href="" onClick="dosomething();"> But this is not the point. If you've read the Bug report i mentioned above you'll see that something goes very wrong if you have empty links. I also don't see what a link like <a href="?PHP_SESSID=1231231"> would do (but it probably would be okay). However, now that i have re2c i found what i think is the real bug. Patch is enclosed. The problem was that you first scan from left to right until you do not find anymore ". Then you do the same from right to left. You then diff both values to find what the url is. With an empty string you get a negative result. That's the real problem. Can you put the patch into cvs if you think it is correct? > > Can someone help me with that? > You can find re2c by going to http://freshmeat.net and entering > re2c into > the search field. Ouch, and i thought i had tried that. Possibly a typo. -- Mit freundlichem Gruß Thomas Stinner - Billiton Internet Services GbR Geschäftsleitung -------------------------------------------------------------- direct phone: 0179/6997983 direct mail: t.stinner@billiton.de Weitere Informationen finden Sie unter http://www.billiton.de/

*** url_scanner.re.orig Tue Mar 28 22:41:07 2000 --- url_scanner.re Wed Mar 29 00:50:51 2000 *************** *** 87,94 **** char c; /* search outer limits for URI */ ! for(p = state->start; p < state->crs && (c = *p); p++) ! if(c != '"' && c != ' ') break; /* * we look at q-1, because q points to the character behind the last --- 87,94 ---- char c; /* search outer limits for URI */ ! p=state->start; ! if (*p == '"' || *p == ' ' || *p == '\'') p++; /* * we look at q-1, because q points to the character behind the last *************** *** 96,103 **** * character */ ! for(q = state->crs; q > state->start && (c = *(q-1)); q--) ! if(c != '"' && c != ' ') break; /* attach beginning */ --- 96,104 ---- * character */ ! q=state->crs; ! if (*(q-1) == '"' || *(q-1) == ' ' || *(q-1) == '\'') q--; ! if (q < p) q=p; /* attach beginning */
« previous php.version4 (#12772) next »