From: Leo Koppelkamm Date: Thu, 21 Apr 2011 07:27:05 +0000 (+0000) Subject: Fix Bug 25794: Disallow multiple table captions & only keep the first X-Git-Tag: 1.31.0-rc.0~30654 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=6e7c9e270194971d7041ddbb16a59c4241c85dc6;p=lhc%2Fweb%2Fwiklou.git Fix Bug 25794: Disallow multiple table captions & only keep the first --- diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 8bcb4167cd..015841607f 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -913,16 +913,17 @@ class Parser { } } else if ( $firstChars === '|+' ) { - // a table caption - $line = substr ( $line , 2 ); - - $c = $this->getCellAttr( $line , 'caption' ); - $table['caption'] = array(); - $table['caption']['content'] = $c[0]; - if ( isset( $c[1] ) ) $table['caption']['attributes'] = $c[1]; - unset( $c ); - - $output =& $table['caption']; + // a table caption, but only proceed if there isn't one already + if ( !isset ( $table['caption'] ) ) { + $line = substr ( $line , 2 ); + + $c = $this->getCellAttr( $line , 'caption' ); + $table['caption'] = array(); + $table['caption']['content'] = $c[0]; + if ( isset( $c[1] ) ) $table['caption']['attributes'] = $c[1]; + unset( $c ); + $output =& $table['caption']['content']; + } } else if ( $firstChars === '|' || $firstChars === '!' || $firstChars === '!+' ) { // Which kind of cells are we dealing with $currentTag = 'td'; diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index 72208feeb8..27e90b63f0 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -1330,6 +1330,39 @@ Table with thead +!! end + +!! test +Table with multiple captions: Only keep first +!! input +{| +|+ caption 1 +|+ caption 2 +|} +!! result + + + +
caption 1 +
+ +!! end + +!! test +Table with multiline caption +!! input +{| +|+ caption 1 +further caption +|} +!! result + + + +
caption 1 +further caption +
+ !! end !! test Table with multiple thead