r80899 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r80898‎ | r80899 | r80900 >
Date:19:40, 24 January 2011
Author:platonides
Status:ok
Tags:
Comment:
Silly bug with value nodes.
Modified paths:
  • /trunk/extensions/NativePreprocessor/Preprocessor_Native.php (modified) (history)
  • /trunk/extensions/NativePreprocessor/nodes.h (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/parser/PreprocessorTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/parser/PreprocessorTest.php
@@ -83,6 +83,7 @@
8484 array( "{{ {{Foo}}", "<root>{{ <template><title>Foo</title></template></root>"),
8585 array( "{{Foobar {{Foo}} {{Bar}} {{Baz}} ", "<root>{{Foobar <template><title>Foo</title></template> <template><title>Bar</title></template> <template><title>Baz</title></template> </root>"),
8686 array( "[[Foo]] |", "<root>[[Foo]] |</root>"),
 87+ array( "{{Foo|Bar|", "<root>{{Foo|Bar|</root>"),
8788 /* array( file_get_contents( dirname( __FILE__ ) . '/QuoteQuran.txt' ), file_get_contents( dirname( __FILE__ ) . '/QuoteQuranExpanded.txt' ) ), */
8889 );
8990 }
Index: trunk/extensions/NativePreprocessor/Preprocessor_Native.php
@@ -37,6 +37,8 @@
3838
3939 const NODE_LEN = 16;
4040 function unserializeNode( $node, $children, &$text ) {
 41+ if ( $node == '' ) throw new MWException( 'Empty node' );
 42+
4143 $flags = ord( $node[1] ) - 48;
4244 $childrenLen = hexdec( substr( $node, 2, 6 ) );
4345 $textLen = hexdec( substr( $node, 8, 8 ) );
Index: trunk/extensions/NativePreprocessor/nodes.h
@@ -278,10 +278,12 @@
279279 }
280280 if (readpos >= *nodeStringLen) break; /* It may be the case for eg. {{Foo|Bar */
281281 int valueChildren = getNextSibling( nodeString + readpos ); /* <value> */
 282+ assert( nodeString[readpos] == value_node ); /* <part> node */
 283+ readpos += NODE_LEN;
282284 if ( valueChildren ) {
283 - memmove( nodeString + writepos, nodeString + readpos, nameChildren );
284 - readpos += nameChildren;
285 - writepos += nameChildren;
 285+ memmove( nodeString + writepos, nodeString + readpos, valueChildren );
 286+ readpos += valueChildren;
 287+ writepos += valueChildren;
286288 }
287289 }
288290 *nodeStringLen = writepos;

Status & tagging log