From 644f1d90671ee067f8492b9f48cc004051c121c5 Mon Sep 17 00:00:00 2001 From: Jens Frank Date: Sun, 29 Aug 2004 19:07:18 +0000 Subject: [PATCH] BUG#244 Backed out changes done in Patch 1.33 due to major security problems. HTML tags were not escaped and it was possible to execute arbitrary javascript code --- includes/DifferenceEngine.php | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/includes/DifferenceEngine.php b/includes/DifferenceEngine.php index 3bc8269938..f4a3a9f8ca 100644 --- a/includes/DifferenceEngine.php +++ b/includes/DifferenceEngine.php @@ -211,8 +211,8 @@ class DifferenceEngine { { global $wgOut, $wgUseExternalDiffEngine; - $otext = str_replace( "\r\n", "\n", $otext ); - $ntext = str_replace( "\r\n", "\n", $ntext ); + $otext = str_replace( "\r\n", "\n", htmlspecialchars( $otext ) ); + $ntext = str_replace( "\r\n", "\n", htmlspecialchars( $ntext ) ); $wgOut->addHTML( "_group !== '') { - if ($this->_tag == 'mark') - $this->_line .= ''.htmlspecialchars ( $this->_group ).''; - else - $this->_line .= htmlspecialchars ( $this->_group ); - } + if ($this->_tag == 'mark') + $this->_line .= ''.$this->_group.''; + else + $this->_line .= $this->_group; + } $this->_group = ''; $this->_tag = $new_tag; } @@ -1166,9 +1166,7 @@ class _HWLDF_WordAccumulator { function _flushLine ($new_tag) { $this->_flushGroup($new_tag); if ($this->_line != '') - array_push ( $this->_lines, $this->_line ); - else - array_push ( $this->_lines, NBSP ); + $this->_lines[] = $this->_line; $this->_line = ''; } @@ -1181,6 +1179,7 @@ class _HWLDF_WordAccumulator { if ($word == '') continue; if ($word[0] == "\n") { + $this->_group .= NBSP; $this->_flushLine($tag); $word = substr($word, 1); } @@ -1207,6 +1206,8 @@ class WordLevelDiff extends MappedDiff } function _split($lines) { + // FIXME: fix POSIX char class. +# if (!preg_match_all('/ ( [^\S\n]+ | [[:alnum:]]+ | . ) (?: (?!< \n) [^\S\n])? /xs', if (!preg_match_all('/ ( [^\S\n]+ | [0-9_A-Za-z\x80-\xff]+ | . ) (?: (?!< \n) [^\S\n])? /xs', implode("\n", $lines), $m)) { @@ -1256,7 +1257,7 @@ class TableDiffFormatter extends DiffFormatter $l2 = wfMsg( 'lineno', $ybeg ); $r = '\n" . - '\n"; + '\n"; return $r; } @@ -1273,12 +1274,12 @@ class TableDiffFormatter extends DiffFormatter function addedLine( $line ) { return ''; + $line.''; } function deletedLine( $line ) { return ''; + $line.''; } function emptyLine() { @@ -1286,22 +1287,21 @@ class TableDiffFormatter extends DiffFormatter } function contextLine( $line ) { - return ''; + return ''; } function _added($lines) { global $wgOut; foreach ($lines as $line) { $wgOut->addHTML( '' . $this->emptyLine() . - $this->addedLine( htmlspecialchars ( $line ) ) . "\n" ); + $this->addedLine( $line ) . "\n" ); } } function _deleted($lines) { global $wgOut; foreach ($lines as $line) { - $wgOut->addHTML( '' . $this->deletedLine( htmlspecialchars ( $line ) ) . + $wgOut->addHTML( '' . $this->deletedLine( $line ) . $this->emptyLine() . "\n" ); } } -- 2.20.1
'.$l1."'.$l2."
'.$l2."
+' . - $line . '-' . - $line . ' ' . - htmlspecialchars ( $line ) . ' '.$line.'