Catrope has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/380890 )
Change subject: BadImageRemover: Update for inline-image change in Parsoid ...................................................................... BadImageRemover: Update for inline-image change in Parsoid Bug: T118520 Change-Id: I80506d71d3f035fdf3970d7619219791640669e3 --- M includes/Parsoid/Fixer/BadImageRemover.php M tests/phpunit/Parsoid/Fixer/BadImageRemoverTest.php 2 files changed, 25 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow refs/changes/90/380890/1 diff --git a/includes/Parsoid/Fixer/BadImageRemover.php b/includes/Parsoid/Fixer/BadImageRemover.php index 8f97675..c2fe067 100644 --- a/includes/Parsoid/Fixer/BadImageRemover.php +++ b/includes/Parsoid/Fixer/BadImageRemover.php @@ -41,7 +41,7 @@ * @return string */ public function getXPath() { - return '//span[@typeof="mw:Image"]//img[@resource]'; + return '//inline-image[@typeof="mw:Image"]//img[@resource] | //span[@typeof="mw:Image"]//img[@resource]'; } /** diff --git a/tests/phpunit/Parsoid/Fixer/BadImageRemoverTest.php b/tests/phpunit/Parsoid/Fixer/BadImageRemoverTest.php index 47c9994..dd7ecba 100644 --- a/tests/phpunit/Parsoid/Fixer/BadImageRemoverTest.php +++ b/tests/phpunit/Parsoid/Fixer/BadImageRemoverTest.php @@ -21,6 +21,18 @@ [ 'Passes through allowed good images', // expected html after filtering + '<p><inline-image class="mw-default-size" typeof="mw:Image"><a href="./File:Image.jpg"><img resource="./File:Image.jpg" src="//upload.wikimedia.org/wikipedia/commons/7/78/Image.jpg" height="500" width="500"></a></inline-image> and other stuff</p>', + // input html + '<p><inline-image class="mw-default-size" typeof="mw:Image"><a href="./File:Image.jpg"><img resource="./File:Image.jpg" src="//upload.wikimedia.org/wikipedia/commons/7/78/Image.jpg" height="500" width="500"></a></inline-image> and other stuff</p>', + // accept/decline callback + function () { + return false; + } + ], + + [ + 'Passes through allowed good images (with legacy span markup)', + // expected html after filtering '<p><span class="mw-default-size" typeof="mw:Image"><a href="./File:Image.jpg"><img resource="./File:Image.jpg" src="//upload.wikimedia.org/wikipedia/commons/7/78/Image.jpg" height="500" width="500"></a></span> and other stuff</p>', // input html '<p><span class="mw-default-size" typeof="mw:Image"><a href="./File:Image.jpg"><img resource="./File:Image.jpg" src="//upload.wikimedia.org/wikipedia/commons/7/78/Image.jpg" height="500" width="500"></a></span> and other stuff</p>', @@ -47,6 +59,18 @@ // expected html after filtering '<p> and other stuff</p>', // input html + '<p><inline-image class="mw-default-size" typeof="mw:Image"><a href="./File:Image.jpg"><img resource="./File:Image.jpg" src="//upload.wikimedia.org/wikipedia/commons/7/78/Image.jpg" height="500" width="500"></a></inline-image> and other stuff</p>', + // accept/decline callback + function () { + return true; + } + ], + + [ + 'Strips declined images (with legacy span markup)', + // expected html after filtering + '<p> and other stuff</p>', + // input html '<p><span class="mw-default-size" typeof="mw:Image"><a href="./File:Image.jpg"><img resource="./File:Image.jpg" src="//upload.wikimedia.org/wikipedia/commons/7/78/Image.jpg" height="500" width="500"></a></span> and other stuff</p>', // accept/decline callback function () { -- To view, visit https://gerrit.wikimedia.org/r/380890 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I80506d71d3f035fdf3970d7619219791640669e3 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Flow Gerrit-Branch: master Gerrit-Owner: Catrope <r...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits