From: Magnus Manske Date: Mon, 6 Feb 2006 15:47:14 +0000 (+0000) Subject: Fixing parser errors "no data" and "nothing but a caption". X-Git-Tag: 1.6.0~366 X-Git-Url: http://git.cyclocoop.org/data/%24oldEdit?a=commitdiff_plain;h=ee35f8c68c7c41ea10b76eb526001ac43e067b57;p=lhc%2Fweb%2Fwiklou.git Fixing parser errors "no data" and "nothing but a caption". This fix is cleaner than the first one; hopefully the test unit will recognize it this time... --- diff --git a/includes/Parser.php b/includes/Parser.php index c45ce68a96..bbe08ae720 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -687,6 +687,7 @@ class Parser $ltd = array () ; # Was it TD or TH? $tr = array () ; # Is currently a tr tag open? $ltr = array () ; # tr attributes + $has_opened_tr = array(); # Did this table open a element? $indent_level = 0; # indent level of the table foreach ( $t AS $k => $x ) { @@ -703,14 +704,15 @@ class Parser array_push ( $ltd , '' ) ; array_push ( $tr , false ) ; array_push ( $ltr , '' ) ; + array_push ( $has_opened_tr, false ); } else if ( count ( $td ) == 0 ) { } # Don't do any of the following else if ( '|}' == substr ( $x , 0 , 2 ) ) { $z = "" . substr ( $x , 2); $l = array_pop ( $ltd ) ; + if ( !array_pop ( $has_opened_tr ) ) $z = "" . $z ; if ( array_pop ( $tr ) ) $z = '' . $z ; if ( array_pop ( $td ) ) $z = '' . $z ; - if ( $l == "" ) $z = "" . $z ; array_pop ( $ltr ) ; $t[$k] = $z . str_repeat( '', $indent_level ); } @@ -719,6 +721,8 @@ class Parser while ( $x != '' && substr ( $x , 0 , 1 ) == '-' ) $x = substr ( $x , 1 ) ; $z = '' ; $l = array_pop ( $ltd ) ; + array_pop ( $has_opened_tr ); + array_push ( $has_opened_tr , true ) ; if ( array_pop ( $tr ) ) $z = '' . $z ; if ( array_pop ( $td ) ) $z = '' . $z ; array_pop ( $ltr ) ; @@ -750,6 +754,8 @@ class Parser if ( !array_pop ( $tr ) ) $z = '\n" ; array_push ( $tr , true ) ; array_push ( $ltr , '' ) ; + array_pop ( $has_opened_tr ); + array_push ( $has_opened_tr , true ) ; } $l = array_pop ( $ltd ) ; @@ -783,9 +789,9 @@ class Parser while ( count ( $td ) > 0 ) { $l = array_pop ( $ltd ) ; - if ( $l == "" ) $t[] = "" ; if ( array_pop ( $td ) ) $t[] = '' ; if ( array_pop ( $tr ) ) $t[] = '' ; + if ( array_pop ( $has_opened_tr ) ) $t[] = "" ; $t[] = '' ; }