Page MenuHomePhabricator

patch-5344.txt

Authored By
bzimport
Nov 21 2014, 9:09 PM
Size
2 KB
Referenced Files
None
Subscribers
None

patch-5344.txt

Index: includes/Parser.php
===================================================================
RCS file: /cvsroot/wikipedia/phase3/includes/Parser.php,v
retrieving revision 1.602
diff -c -r1.602 Parser.php
*** includes/Parser.php 22 Mar 2006 04:57:14 -0000 1.602
--- includes/Parser.php 24 Mar 2006 14:52:21 -0000
***************
*** 303,324 ****
}
if( $tag == STRIP_COMMENTS ) {
! $start = '/<!--()()/';
$end = '/-->/';
} else {
! $start = "/<$tag(\\s+[^\\/>]*|\\s*)(\\/?)>/i";
$end = "/<\\/$tag\\s*>/i";
}
!
while ( '' != $text ) {
$p = preg_split( $start, $text, 2, PREG_SPLIT_DELIM_CAPTURE );
$stripped .= $p[0];
! if( count( $p ) < 4 ) {
break;
}
$attributes = $p[1];
! $empty = $p[2];
! $inside = $p[3];
$marker = $rnd . sprintf('%08X', $n++);
$stripped .= $marker;
--- 303,332 ----
}
if( $tag == STRIP_COMMENTS ) {
! $start = '/<!--()/';
$end = '/-->/';
} else {
! $start = "/<$tag(\\s+[^>]*|\\s*\/?)>/i";
$end = "/<\\/$tag\\s*>/i";
}
!
while ( '' != $text ) {
$p = preg_split( $start, $text, 2, PREG_SPLIT_DELIM_CAPTURE );
$stripped .= $p[0];
! if( count( $p ) < 3 ) {
break;
}
$attributes = $p[1];
! $inside = $p[2];
!
! // If $attributes ends with '/', we have an empty element tag, <tag />
! if ( $tag != STRIP_COMMENTS && substr( $attributes, -1 ) == '/' ) {
! $attributes = substr( $attributes, 0, -1);
! $empty = '/';
! }
! else {
! $empty = '';
! }
$marker = $rnd . sprintf('%08X', $n++);
$stripped .= $marker;
***************
*** 327,333 ****
$params[$marker] = Sanitizer::decodeTagAttributes( $attributes );
if ( $empty === '/' ) {
- // Empty element tag, <tag />
$content[$marker] = null;
$text = $inside;
} else {
--- 335,340 ----
Index: maintenance/parserTests.txt
===================================================================
RCS file: /cvsroot/wikipedia/phase3/maintenance/parserTests.txt,v
retrieving revision 1.124
diff -c -r1.124 parserTests.txt
*** maintenance/parserTests.txt 17 Mar 2006 01:02:14 -0000 1.124
--- maintenance/parserTests.txt 24 Mar 2006 14:52:21 -0000
***************
*** 3501,3506 ****
--- 3501,3521 ----
!! end
!! test
+ Parser hook: argument containing a forward slash (bug 5344)
+ !! input
+ <tag filename='/tmp/bla'></tag>
+ !! result
+ <pre>
+ string(0) ""
+ array(1) {
+ ["filename"]=>
+ string(8) "/tmp/bla"
+ }
+ </pre>
+
+ !! end
+
+ !! test
Parser hook: empty input using terminated empty elements (bug 2374)
!! input
<tag foo=bar/>text

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2265
Default Alt Text
patch-5344.txt (2 KB)

Event Timeline