Index: trunk/phase3/tests/phpunit/includes/parser/PreprocessorTest.php |
— | — | @@ -83,6 +83,7 @@ |
84 | 84 | array( "{{ {{Foo}}", "<root>{{ <template><title>Foo</title></template></root>"), |
85 | 85 | array( "{{Foobar {{Foo}} {{Bar}} {{Baz}} ", "<root>{{Foobar <template><title>Foo</title></template> <template><title>Bar</title></template> <template><title>Baz</title></template> </root>"), |
86 | 86 | array( "[[Foo]] |", "<root>[[Foo]] |</root>"), |
| 87 | + array( "{{Foo|Bar|", "<root>{{Foo|Bar|</root>"), |
87 | 88 | /* array( file_get_contents( dirname( __FILE__ ) . '/QuoteQuran.txt' ), file_get_contents( dirname( __FILE__ ) . '/QuoteQuranExpanded.txt' ) ), */ |
88 | 89 | ); |
89 | 90 | } |
Index: trunk/extensions/NativePreprocessor/Preprocessor_Native.php |
— | — | @@ -37,6 +37,8 @@ |
38 | 38 | |
39 | 39 | const NODE_LEN = 16; |
40 | 40 | function unserializeNode( $node, $children, &$text ) { |
| 41 | + if ( $node == '' ) throw new MWException( 'Empty node' ); |
| 42 | + |
41 | 43 | $flags = ord( $node[1] ) - 48; |
42 | 44 | $childrenLen = hexdec( substr( $node, 2, 6 ) ); |
43 | 45 | $textLen = hexdec( substr( $node, 8, 8 ) ); |
Index: trunk/extensions/NativePreprocessor/nodes.h |
— | — | @@ -278,10 +278,12 @@ |
279 | 279 | } |
280 | 280 | if (readpos >= *nodeStringLen) break; /* It may be the case for eg. {{Foo|Bar */ |
281 | 281 | int valueChildren = getNextSibling( nodeString + readpos ); /* <value> */ |
| 282 | + assert( nodeString[readpos] == value_node ); /* <part> node */ |
| 283 | + readpos += NODE_LEN; |
282 | 284 | 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; |
286 | 288 | } |
287 | 289 | } |
288 | 290 | *nodeStringLen = writepos; |