Error in regexp in function add_pingback

Found a bug? Tell us!!
Post Reply
dhaun
Posts: 2
Joined: Sun Feb 11, 2007 8:33 pm

Error in regexp in function add_pingback

Post by dhaun »

When S9Y receives a Pingback, it parses the XML with one giant preg_match in function add_pingback in include/functions_trackbacks.inc.php

However, that regexp has two subtle errors that prevent it from successfully parsing the URLs (source and target) out of the XML.

Code: Select all

if(preg_match('@<methodcall>\s*<methodName>\s*pingback.ping\s*</methodName>\s*<params>\s*<param>\s*<value>\s*<string>([^<])*</string>\s*</value>\s*</param>\s*<param>\s*<value>\s*<string>([^<])*</string>\s*</value>\s*</param>\s*</params>\s*</methodCall>@i', $postdata, $matches)) {
The problem is with the two occurences of ([^<])* - they should both read ([^<]*). Otherwise, you'll only get the last character of the URL ...

Fixed version:

Code: Select all

if(preg_match('@<methodcall>\s*<methodName>\s*pingback.ping\s*</methodName>\s*<params>\s*<param>\s*<value>\s*<string>([^<]*)</string>\s*</value>\s*</param>\s*<param>\s*<value>\s*<string>([^<]*)</string>\s*</value>\s*</param>\s*</params>\s*</methodCall>@i', $postdata, $matches)) {
This is in Serendipity 1.1, downloaded today.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Error in regexp in function add_pingback

Post by garvinhicking »

Hi!

Thanks a lot, a very good catch. I just committed your fix!

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
dhaun
Posts: 2
Joined: Sun Feb 11, 2007 8:33 pm

Post by dhaun »

Actually, even with that fix, Serendipity doesn't seem to handle Pingbacks correctly. It stores them in the database, updates the Trackback counter - but doesn't display them.

So now I have (on my local test install) articles that proudly display "Trackbacks (1)" - but there is no Trackback or Pingback being displayed.

I leave that for someone else to debug :wink: but my guess is that is has something to do with the fact that a Pingback doesn't contain a title or a body text.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!
dhaun wrote:Actually, even with that fix, Serendipity doesn't seem to handle Pingbacks correctly. It stores them in the database, updates the Trackback counter - but doesn't display them.
That might be true. I've sadly never worked with Pingbacks, that logic was in the s9y core before I joined the project. since I personally didn't ever care about pingbacks I never investigated it. So, yes, the functionality to display them might be completely missing.

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply