From: Brion Vibber Date: Sat, 10 Apr 2004 04:28:19 +0000 (+0000) Subject: Try to escape unaccompanied ampersands. X-Git-Tag: 1.3.0beta1~486 X-Git-Url: https://git.cyclocoop.org//%22?a=commitdiff_plain;h=c27d8f8bfa37fd56fc607d9e5ccb8d134940e5b5;p=lhc%2Fweb%2Fwiklou.git Try to escape unaccompanied ampersands. This doesn't yet verify that named character entities are valid, however. --- diff --git a/includes/Parser.php b/includes/Parser.php index 1bec4abc3a..548f8ff1a1 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -495,12 +495,13 @@ class Parser "/<\\/center *>/i" => '' ); $text = preg_replace( array_keys($fixtags), array_values($fixtags), $text ); - // another round, but without regex - $fixtags = array( - '& ' => '&', - '&<' => '&<', - ); - $text = str_replace( array_keys($fixtags), array_values($fixtags), $text ); + + # Clean up spare ampersands; note that we probably ought to be + # more careful about named entities. + $text = preg_replace( + '/&(?!:amp;|#[Xx][0-9A-fa-f]+;|#[0-9]+;|[a-zA-Z0-9]+;)/', + '&', + $text ); $text .= $this->categoryMagic () ;