Page 1 of 1

Error in regexp in function add_pingback

Posted: Sun Feb 11, 2007 8:40 pm
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.

Re: Error in regexp in function add_pingback

Posted: Mon Feb 12, 2007 1:13 pm
by garvinhicking
Hi!

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

Best regards,
Garvin

Posted: Mon Feb 12, 2007 5:23 pm
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.

Posted: Tue Feb 13, 2007 9:37 am
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