Page MenuHomePhabricator

fix5718.patch.2

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

fix5718.patch.2

Index: includes/parser/Parser.php
===================================================================
--- includes/parser/Parser.php (revision 60487)
+++ includes/parser/Parser.php (working copy)
@@ -2052,15 +2052,33 @@
// If we have no prefixes, go to paragraph mode.
if( 0 == $prefixLength ) {
wfProfileIn( __METHOD__."-paragraph" );
- # No prefix (not in list)--go to paragraph mode
// XXX: use a stack for nestable elements like span, table and div
- $openmatch = preg_match('/(?:<table|<blockquote|<h1|<h2|<h3|<h4|<h5|<h6|<pre|<tr|<p|<ul|<ol|<li|<\\/tr|<\\/td|<\\/th)/iS', $t );
+ // Note: <div> is matched by closematch not openmatch therefore
+ // $inBlockElem == false
+ $openblock = array();
+ $openmatch = preg_match('/(?:<table|<blockquote|<h1|<h2|<h3|<h4|<h5|<h6|<pre|<tr|<p|<ul|<ol|<li|<\\/tr|<\\/td|<\\/th)/iS',
+ $t, $openblock, PREG_OFFSET_CAPTURE);
+ $closeblock = array();
$closematch = preg_match(
'/(?:<\\/table|<\\/blockquote|<\\/h1|<\\/h2|<\\/h3|<\\/h4|<\\/h5|<\\/h6|'.
- '<td|<th|<\\/?div|<hr|<\\/pre|<\\/p|'.$this->mUniqPrefix.'-pre|<\\/li|<\\/ul|<\\/ol|<\\/?center)/iS', $t );
+ '<td|<th|<\\/?div|<hr|<\\/pre|<\\/p|'.$this->mUniqPrefix.'-pre|<\\/li|<\\/ul|<\\/ol|<\\/?center)/iS',
+ $t, $closeblock, PREG_OFFSET_CAPTURE);
if ( $openmatch or $closematch ) {
$paragraphStack = false;
- # TODO bug 5718: paragraph closed
+ #TODO bug 5718: paragraph closed
+ $tagstart = -1;
+ if ($openmatch) {
+ $tagstart = $openblock[0][1];
+ } else {
+ $tagstart = $closeblock[0][1];
+ }
+ if (!preg_match('/<\\/?div/', $t)) {
+ // FIXME: Handle div as a special case to stay
+ // consistent with old behavior after fixing
+ // bug 5718, but div processing needs to be fixed.
+ $output .= substr($t, 0, $tagstart);
+ $t = substr($t, $tagstart);
+ }
$output .= $this->closeParagraph();
if ( $preOpenMatch and !$preCloseMatch ) {
$this->mInPre = true;
@@ -2089,6 +2107,9 @@
} else {
if ($this->mLastSection !== 'p' ) {
$output .= $this->closeParagraph();
+ // FIXME: closeParagraph will clear
+ // mLastSection. Don't need to do that in
+ // both places.
$this->mLastSection = '';
$paragraphStack = '<p>';
} else {

File Metadata

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

Event Timeline