Ticket #4820 (closed defect: fixed)

Opened 1 year ago

Last modified 1 year ago

Regex fix for $pagelinkedfrom (xmlrpc.php)

Reported by: tenpura Assigned to: anonymous
Priority: high Milestone: 2.3
Component: XML-RPC Version: 2.3
Severity: normal Keywords: has-patch
Cc: josephscott

Description

xmlrpc.php line 1937:

$pagelinkedfrom = preg_replace('#&([^amp\;])#is', '&$1', $pagelinkedfrom);

doesn't seem to work like it was intended. It should be something like:

$pagelinkedfrom = preg_replace('#amp;#is', '&', $pagelinkedfrom);
$pagelinkedfrom = preg_replace('#&(.)#is', '&$1', $pagelinkedfrom);

Attachments

4820.patch (0.9 kB) - added by tenpura on 08/28/07 05:39:56.

Change History

08/26/07 20:11:17 changed by tenpura

Oops, It should be like:

$pagelinkedfrom = preg_replace('#&#is', '&', $pagelinkedfrom);
$pagelinkedfrom = preg_replace('#&(.)#is', '&$1', $pagelinkedfrom);

08/27/07 05:20:11 changed by josephscott

  • cc set to josephscott.

08/27/07 14:05:50 changed by josephscott

It looks like your first item:

$pagelinkedfrom = preg_replace('#&#is', '&', $pagelinkedfrom);

is already being done on 1810 using str_replace:

$pagelinkedfrom = str_replace('&', '&', $pagelinkedfrom);

Is there a specific example of where the current code doesn't work as expected?

08/28/07 05:39:56 changed by tenpura

  • attachment 4820.patch added.

08/28/07 05:42:27 changed by tenpura

  • keywords set to has-patch.

I found another one to fix. Please see the attachment.

Is there a specific example of where the current code doesn't work as expected?

Yes. The current code contains a misuse of character class (Square brackets).

Example:

$pagelinkedfrom = '&a=1&m=2&p=3&ok=4&';
$pagelinkedfrom = preg_replace('#&([^amp\;])#is', '&$1', $pagelinkedfrom);
echo $pagelinkedfrom; // result is &a=1&m=2&p=3&ok=4&

09/12/07 22:40:23 changed by ryan

  • priority changed from normal to high.

09/18/07 16:42:25 changed by ryan

  • status changed from new to closed.
  • resolution set to fixed.

(In [6127]) Replace faulty regex. Props tenpura. fixes #4820