Make WordPress Core

Opened 18 years ago

Closed 18 years ago

#4820 closed defect (bug) (fixed)

Regex fix for $pagelinkedfrom (xmlrpc.php)

Reported by: tenpura's profile tenpura Owned by:
Milestone: 2.3 Priority: high
Severity: normal Version: 2.3
Component: XML-RPC Keywords: has-patch
Focuses: Cc:

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 (1)

4820.patch (954 bytes) - added by tenpura 18 years ago.

Download all attachments as: .zip

Change History (7)

#1 @tenpura
18 years ago

Oops, It should be like:

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

#2 @josephscott
18 years ago

  • Cc josephscott added

#3 @josephscott
18 years ago

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?

@tenpura
18 years ago

#4 @tenpura
18 years ago

  • Keywords has-patch added

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&

#5 @ryan
18 years ago

  • Priority changed from normal to high

#6 @ryan
18 years ago

  • Resolution set to fixed
  • Status changed from new to closed

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

Note: See TracTickets for help on using tickets.