Tpt has uploaded a new change for review.

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

Change subject: More lenient <pagequality> parser
......................................................................

More lenient <pagequality> parser

Change-Id: I577f5f4027f5a245dd88c2fd3324519ff0d29ccf
---
M includes/page/PageContentHandler.php
M tests/includes/page/PageContentHandlerTest.php
2 files changed, 4 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ProofreadPage 
refs/changes/27/295527/1

diff --git a/includes/page/PageContentHandler.php 
b/includes/page/PageContentHandler.php
index aa5a37a..9ba34b2 100644
--- a/includes/page/PageContentHandler.php
+++ b/includes/page/PageContentHandler.php
@@ -152,7 +152,7 @@
                        $body = $text;
                }
 
-               if ( preg_match( '/^<pagequality level="(0|1|2|3|4)" 
user="(.*?)" \/>(.*?)$/s', $header, $m ) ) {
+               if ( preg_match( '/^<pagequality level="(0|1|2|3|4)" 
user="(.*?)" *(\/>|> *</pagequality>)(.*?)$/s', $header, $m ) ) {
                        $level = intval( $m[1] );
                        $proofreader = $m[2];
                        $header = $this->cleanHeader( $m[3] );
diff --git a/tests/includes/page/PageContentHandlerTest.php 
b/tests/includes/page/PageContentHandlerTest.php
index d0a4015..532889f 100644
--- a/tests/includes/page/PageContentHandlerTest.php
+++ b/tests/includes/page/PageContentHandlerTest.php
@@ -32,7 +32,9 @@
                        [ 'Experimental header', 'Experimental body', 
'Experimental footer', 2, 'Woot', '<noinclude><pagequality level="2" 
user="Woot" /><div class="pagetext">Experimental header' . "\n\n\n" . 
'</noinclude>Experimental body<noinclude>Experimental footer</div></noinclude>' 
],
                        [ 'Experimental header', 'Experimental body', '', 2, 
'Woot', '<noinclude><pagequality level="2" user="Woot" /><div>Experimental 
header' . "\n\n\n" . '</noinclude>Experimental body</div>' ],
                        [ 'Experimental header', 'Experimental 
<noinclude>body</noinclude>', 'Experimental footer', 2, 'Woot', 
'<noinclude><pagequality level="2" user="Woot" /><div 
class="pagetext">Experimental header' . "\n\n\n" . '</noinclude>Experimental 
<noinclude>body</noinclude><noinclude>Experimental footer</div></noinclude>' ],
-                       [ 'Experimental header', 'Experimental body', 
'Experimental footer', 2, 'Woot', '<noinclude><pagequality level="2" 
user="Woot" /><div class="pagetext">Experimental header' . "\n" . 
'</noinclude>Experimental body<noinclude>Experimental footer</div></noinclude>' 
]
+                       [ 'Experimental header', 'Experimental body', 
'Experimental footer', 2, 'Woot', '<noinclude><pagequality level="2" 
user="Woot" /><div class="pagetext">Experimental header' . "\n" . 
'</noinclude>Experimental body<noinclude>Experimental footer</div></noinclude>' 
],
+                       [ 'Experimental header', 'Experimental body', 
'Experimental footer', 2, 'Woot', '<noinclude><pagequality level="2" 
user="Woot" />Experimental header' . "\n" . '</noinclude>Experimental 
body<noinclude>Experimental footer</noinclude>' ],
+                       [ 'Experimental header', 'Experimental body', 
'Experimental footer', 2, 'Woot', '<noinclude><pagequality level="2" 
user="Woot"></pagequality>Experimental header' . "\n" . 
'</noinclude>Experimental body<noinclude>Experimental footer</div></noinclude>' 
]
                ];
        }
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I577f5f4027f5a245dd88c2fd3324519ff0d29ccf
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ProofreadPage
Gerrit-Branch: master
Gerrit-Owner: Tpt <thoma...@hotmail.fr>

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

Reply via email to