Welcome to Geeklog, Anonymous Sunday, January 05 2025 @ 01:36 am EST
Geeklog Forums
Interesting Flaw
Status: offline
eyecravedvd
Forum User
Full Member
Registered: 06/09/03
Posts: 152
I've been using GL since 1.1 and it's a great product, which continually gets better.
I just ran across this interesting little flaw that maybe some can look into.
When you do a search for an article and pull up that particular article in changes the case of the searched text in the article and adds slashes to anything that stripslashes() typically removes.
Here is an example: searched for "lord of the rings" sans quotes.
Search String Story
Regular Article
Shane | www.EyeCraveDVD.com
I just ran across this interesting little flaw that maybe some can look into.
When you do a search for an article and pull up that particular article in changes the case of the searched text in the article and adds slashes to anything that stripslashes() typically removes.
Here is an example: searched for "lord of the rings" sans quotes.
Search String Story
Regular Article
Shane | www.EyeCraveDVD.com
2
4
Quote
Status: offline
eyecravedvd
Forum User
Full Member
Registered: 06/09/03
Posts: 152
I guess I should also mention I'm using the latest version of 1.3.8-1.... I think it's sr4 although the bottom of my site still says sr3.
Shane | www.EyeCraveDVD.com
Shane | www.EyeCraveDVD.com
3
7
Quote
Status: offline
Dirk
Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Can't get to your site right now, but I think I know what you mean. It's caused by the regexp doing the highlighting.
If anyone with better regexp-fu can come up with a better solution, I'd be happy to integrate it ...
bye, Dirk
If anyone with better regexp-fu can come up with a better solution, I'd be happy to integrate it ...
bye, Dirk
6
4
Quote
Status: offline
eyecravedvd
Forum User
Full Member
Registered: 06/09/03
Posts: 152
Hey Dirk,
Where is that code located. I have a friend who really knows and understands it. He would like to have a crack at it and see if we can resolve it.
Thanks,
Shane
Shane | www.EyeCraveDVD.com
Where is that code located. I have a friend who really knows and understands it. He would like to have a crack at it and see if we can resolve it.
Thanks,
Shane
Shane | www.EyeCraveDVD.com
5
11
Quote
Status: offline
asmaloney
Forum User
Full Member
Registered: 02/08/04
Posts: 214
In article.php you'll find this code around line 133:
if ($query) {
$mywords = explode (" ", $query);
foreach ($mywords as $searchword) {
$A['introtext'] = preg_replace ("/(>(((?>[^><]+)|(?R))*)<)/ie", "preg_replace('/(?>$searchword+)/i','<span class="highlight">$searchword</span>','\0')", "<x>" . $A['introtext'] . "<x>");
$A['bodytext'] = preg_replace ("/(>(((?>[^><]+)|(?R))*)<)/ie", "preg_replace('/(?>$searchword+)/i','<span class="highlight">$searchword</span>','\0')" ,"<x>" . $A['bodytext'] . "<x>");
}
}
It looks like matches in the article are marked with '>>>' and '<<<' and then matched and replaced as above. The problem is that it does a case insensitive search, but uses '$searchword' as the replacement. Because this is all nesty-ugly, it's not a strightforward fix.
Text Formatted Code
if ($query) {
$mywords = explode (" ", $query);
foreach ($mywords as $searchword) {
$A['introtext'] = preg_replace ("/(>(((?>[^><]+)|(?R))*)<)/ie", "preg_replace('/(?>$searchword+)/i','<span class="highlight">$searchword</span>','\0')", "<x>" . $A['introtext'] . "<x>");
$A['bodytext'] = preg_replace ("/(>(((?>[^><]+)|(?R))*)<)/ie", "preg_replace('/(?>$searchword+)/i','<span class="highlight">$searchword</span>','\0')" ,"<x>" . $A['bodytext'] . "<x>");
}
}
It looks like matches in the article are marked with '>>>' and '<<<' and then matched and replaced as above. The problem is that it does a case insensitive search, but uses '$searchword' as the replacement. Because this is all nesty-ugly, it's not a strightforward fix.
3
4
Quote
All times are EST. The time is now 01:36 am.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content