MaxSem has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/81507


Change subject: Fix spaces after references
......................................................................

Fix spaces after references

Bug: 53086
Change-Id: I92ff7d38c5360953a487866f7d90564d58c519f3
---
M includes/formatters/HtmlFormatter.php
M tests/HtmlFormatterTest.php
2 files changed, 12 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/07/81507/1

diff --git a/includes/formatters/HtmlFormatter.php 
b/includes/formatters/HtmlFormatter.php
index c9485ea..03ee8f2 100644
--- a/includes/formatters/HtmlFormatter.php
+++ b/includes/formatters/HtmlFormatter.php
@@ -50,12 +50,15 @@
        public function getDoc() {
                if ( !$this->doc ) {
                        $html = mb_convert_encoding( $this->html, 
'HTML-ENTITIES', "UTF-8" );
+
+                       // https://bugzilla.wikimedia.org/show_bug.cgi?id=53086
+                       $html = str_replace( ' <', '&#32;<', $html );
+
                        libxml_use_internal_errors( true );
                        $this->doc = new DOMDocument();
+                       $this->doc->strictErrorChecking = false;
                        $this->doc->loadHTML( $html );
                        libxml_use_internal_errors( false );
-                       $this->doc->preserveWhiteSpace = false;
-                       $this->doc->strictErrorChecking = false;
                        $this->doc->encoding = 'UTF-8';
                }
                return $this->doc;
@@ -309,6 +312,7 @@
                                $body->appendChild( $element );
                        }
                        $html = $this->doc->saveHTML();
+                       //var_dump($html);die;
                        $html = $this->fixLibXml( $html );
                } else {
                        $html = $this->html;
diff --git a/tests/HtmlFormatterTest.php b/tests/HtmlFormatterTest.php
index a9a141b..5ece668 100644
--- a/tests/HtmlFormatterTest.php
+++ b/tests/HtmlFormatterTest.php
@@ -106,7 +106,12 @@
                                '<span class="mw-mf-image-replacement">[' . 
wfMessage( 'mobile-frontend-missing-image' ) . ']</span>look at the cute 
kitty!'.
                                        '<span 
class="mw-mf-image-replacement">[picture of angry dog]</span>',
                                $removeImages,
-                       )
+                       ),
+                       // https://bugzilla.wikimedia.org/show_bug.cgi?id=53086
+                       array(
+                               'Foo<sup id="cite_ref-1" class="reference"><a 
href="#cite_note-1">[1]</a></sup> <a href="/wiki/Bar" title="Bar" 
class="mw-redirect">Bar</a>',
+                               'Foo<sup id="cite_ref-1" class="reference"><a 
href="#cite_note-1">[1]</a></sup> <a href="/wiki/Bar" title="Bar" 
class="mw-redirect">Bar</a>',
+                       ),
                );
        }
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/81507
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I92ff7d38c5360953a487866f7d90564d58c519f3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: MaxSem <maxsem.w...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to