WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#4820 closed defect (bug) (fixed)

Regex fix for $pagelinkedfrom (xmlrpc.php)

Reported by: 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 7 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 tenpura7 years ago

Oops, It should be like:

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

comment:2 josephscott7 years ago

  • Cc josephscott added

comment:3 josephscott7 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?

tenpura7 years ago

comment:4 tenpura7 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&

comment:5 ryan7 years ago

  • Priority changed from normal to high

comment:6 ryan7 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.