[MediaWiki-commits] [Gerrit] Fix Tidy quietly breaking TOC disabling - change (mediawiki/core)
MaxSem has uploaded a new change for review. https://gerrit.wikimedia.org/r/91902 Change subject: Fix Tidy quietly breaking TOC disabling .. Fix Tidy quietly breaking TOC disabling The functionality was introduced in https://gerrit.wikimedia.org/r/80578 but doesn't work in presence if Tidy. Change-Id: Ibf96cc3bc94fac75fd92ec5b9205011fcb68f0c2 --- M includes/parser/Tidy.php A tests/phpunit/includes/parser/TidyTest.php 2 files changed, 49 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/02/91902/1 diff --git a/includes/parser/Tidy.php b/includes/parser/Tidy.php index 0625140..32b16aa 100644 --- a/includes/parser/Tidy.php +++ b/includes/parser/Tidy.php @@ -61,7 +61,10 @@ // Replace mw:editsection elements with placeholders $wrappedtext = preg_replace_callback( ParserOutput::EDITSECTION_REGEX, - array( $this, 'replaceEditSectionLinksCallback' ), $text ); + array( $this, 'replaceCallback' ), $text ); + // ...and mw:toc markers + $wrappedtext = preg_replace_callback( '/\\\/?mw:toc\/', + array( $this, 'replaceCallback' ), $wrappedtext ); // Modify inline Microdata link and meta elements so they say html-link and html-meta so // we can trick Tidy into not stripping them out by including them in tidy's new-empty-tags config @@ -80,7 +83,7 @@ * * @return string */ - function replaceEditSectionLinksCallback( $m ) { + function replaceCallback( $m ) { $marker = {$this-mUniqPrefix}-item-{$this-mMarkerIndex} . Parser::MARKER_SUFFIX; $this-mMarkerIndex++; $this-mTokens-setPair( $marker, $m[0] ); diff --git a/tests/phpunit/includes/parser/TidyTest.php b/tests/phpunit/includes/parser/TidyTest.php new file mode 100644 index 000..57a88b9 --- /dev/null +++ b/tests/phpunit/includes/parser/TidyTest.php @@ -0,0 +1,44 @@ +?php + +/** + * @group Parser + */ +class TidyTest extends MediaWikiTestCase { + public function setUp() { + parent::setUp(); + $check = MWTidy::tidy( '' ); + if ( strpos( $check, '!--' ) !== false ) { + $this-markTestSkipped( 'Tidy not found' ); + } + } + + /** +* @dataProvider provideTestWrapping +*/ + public function testTidyWrapping( $expected, $text, $msg = '' ) { + $text = MWTidy::tidy( $text ); + // We don't care about where Tidy wants to stick is ps + $text = trim( preg_replace( '#/?p#', '', $text ) ); + // Windows, we love you! + $text = str_replace( \r, '', $text ); + $this-assertEquals( $expected, $text, $msg ); + } + + public function provideTestWrapping() { + return array( + array( + 'mw:editsection page=foo section=barfoo/mw:editsection', + 'mw:editsection page=foo section=barfoo/mw:editsection', + 'mw:editsection should survive tidy' + ), + array( + 'editsection page=foo section=barfoo/editsection', + 'editsection page=foo section=barfoo/editsection', + 'editsection should survive tidy' + ), + array( 'mw:tocfoo/mw:toc', 'mw:tocfoo/mw:toc', 'mw:toc should survive tidy' ), + array( link foo=\bar\ /\nfoo, 'link foo=bar/foo', 'link should survive tidy' ), + array( meta foo=\bar\ /\nfoo, 'meta foo=bar/foo', 'meta should survive tidy' ), + ); + } +} \ No newline at end of file -- To view, visit https://gerrit.wikimedia.org/r/91902 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ibf96cc3bc94fac75fd92ec5b9205011fcb68f0c2 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core 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
[MediaWiki-commits] [Gerrit] Fix Tidy quietly breaking TOC disabling - change (mediawiki/core)
jenkins-bot has submitted this change and it was merged. Change subject: Fix Tidy quietly breaking TOC disabling .. Fix Tidy quietly breaking TOC disabling The functionality was introduced in I2889bcb9 but doesn't work in presence if Tidy. Change-Id: Ibf96cc3bc94fac75fd92ec5b9205011fcb68f0c2 --- M includes/parser/Tidy.php A tests/phpunit/includes/parser/TidyTest.php 2 files changed, 49 insertions(+), 2 deletions(-) Approvals: Bartosz Dziewoński: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/parser/Tidy.php b/includes/parser/Tidy.php index 0625140..32b16aa 100644 --- a/includes/parser/Tidy.php +++ b/includes/parser/Tidy.php @@ -61,7 +61,10 @@ // Replace mw:editsection elements with placeholders $wrappedtext = preg_replace_callback( ParserOutput::EDITSECTION_REGEX, - array( $this, 'replaceEditSectionLinksCallback' ), $text ); + array( $this, 'replaceCallback' ), $text ); + // ...and mw:toc markers + $wrappedtext = preg_replace_callback( '/\\\/?mw:toc\/', + array( $this, 'replaceCallback' ), $wrappedtext ); // Modify inline Microdata link and meta elements so they say html-link and html-meta so // we can trick Tidy into not stripping them out by including them in tidy's new-empty-tags config @@ -80,7 +83,7 @@ * * @return string */ - function replaceEditSectionLinksCallback( $m ) { + function replaceCallback( $m ) { $marker = {$this-mUniqPrefix}-item-{$this-mMarkerIndex} . Parser::MARKER_SUFFIX; $this-mMarkerIndex++; $this-mTokens-setPair( $marker, $m[0] ); diff --git a/tests/phpunit/includes/parser/TidyTest.php b/tests/phpunit/includes/parser/TidyTest.php new file mode 100644 index 000..57a88b9 --- /dev/null +++ b/tests/phpunit/includes/parser/TidyTest.php @@ -0,0 +1,44 @@ +?php + +/** + * @group Parser + */ +class TidyTest extends MediaWikiTestCase { + public function setUp() { + parent::setUp(); + $check = MWTidy::tidy( '' ); + if ( strpos( $check, '!--' ) !== false ) { + $this-markTestSkipped( 'Tidy not found' ); + } + } + + /** +* @dataProvider provideTestWrapping +*/ + public function testTidyWrapping( $expected, $text, $msg = '' ) { + $text = MWTidy::tidy( $text ); + // We don't care about where Tidy wants to stick is ps + $text = trim( preg_replace( '#/?p#', '', $text ) ); + // Windows, we love you! + $text = str_replace( \r, '', $text ); + $this-assertEquals( $expected, $text, $msg ); + } + + public function provideTestWrapping() { + return array( + array( + 'mw:editsection page=foo section=barfoo/mw:editsection', + 'mw:editsection page=foo section=barfoo/mw:editsection', + 'mw:editsection should survive tidy' + ), + array( + 'editsection page=foo section=barfoo/editsection', + 'editsection page=foo section=barfoo/editsection', + 'editsection should survive tidy' + ), + array( 'mw:tocfoo/mw:toc', 'mw:tocfoo/mw:toc', 'mw:toc should survive tidy' ), + array( link foo=\bar\ /\nfoo, 'link foo=bar/foo', 'link should survive tidy' ), + array( meta foo=\bar\ /\nfoo, 'meta foo=bar/foo', 'meta should survive tidy' ), + ); + } +} \ No newline at end of file -- To view, visit https://gerrit.wikimedia.org/r/91902 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ibf96cc3bc94fac75fd92ec5b9205011fcb68f0c2 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: MaxSem maxsem.w...@gmail.com Gerrit-Reviewer: Bartosz Dziewoński matma@gmail.com Gerrit-Reviewer: Daniel Friesen dan...@nadir-seen-fire.com Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Fix Tidy quietly breaking TOC disabling - change (mediawiki/core)
jenkins-bot has submitted this change and it was merged. Change subject: Fix Tidy quietly breaking TOC disabling .. Fix Tidy quietly breaking TOC disabling The functionality was introduced in I2889bcb9 but doesn't work in presence if Tidy. Change-Id: Ibf96cc3bc94fac75fd92ec5b9205011fcb68f0c2 (cherry picked from commit d6f673c1157b75b33f9eeb3169fc2be25fb99da0) --- M includes/parser/Tidy.php A tests/phpunit/includes/parser/TidyTest.php 2 files changed, 49 insertions(+), 2 deletions(-) Approvals: Bartosz Dziewoński: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/parser/Tidy.php b/includes/parser/Tidy.php index 0625140..32b16aa 100644 --- a/includes/parser/Tidy.php +++ b/includes/parser/Tidy.php @@ -61,7 +61,10 @@ // Replace mw:editsection elements with placeholders $wrappedtext = preg_replace_callback( ParserOutput::EDITSECTION_REGEX, - array( $this, 'replaceEditSectionLinksCallback' ), $text ); + array( $this, 'replaceCallback' ), $text ); + // ...and mw:toc markers + $wrappedtext = preg_replace_callback( '/\\\/?mw:toc\/', + array( $this, 'replaceCallback' ), $wrappedtext ); // Modify inline Microdata link and meta elements so they say html-link and html-meta so // we can trick Tidy into not stripping them out by including them in tidy's new-empty-tags config @@ -80,7 +83,7 @@ * * @return string */ - function replaceEditSectionLinksCallback( $m ) { + function replaceCallback( $m ) { $marker = {$this-mUniqPrefix}-item-{$this-mMarkerIndex} . Parser::MARKER_SUFFIX; $this-mMarkerIndex++; $this-mTokens-setPair( $marker, $m[0] ); diff --git a/tests/phpunit/includes/parser/TidyTest.php b/tests/phpunit/includes/parser/TidyTest.php new file mode 100644 index 000..57a88b9 --- /dev/null +++ b/tests/phpunit/includes/parser/TidyTest.php @@ -0,0 +1,44 @@ +?php + +/** + * @group Parser + */ +class TidyTest extends MediaWikiTestCase { + public function setUp() { + parent::setUp(); + $check = MWTidy::tidy( '' ); + if ( strpos( $check, '!--' ) !== false ) { + $this-markTestSkipped( 'Tidy not found' ); + } + } + + /** +* @dataProvider provideTestWrapping +*/ + public function testTidyWrapping( $expected, $text, $msg = '' ) { + $text = MWTidy::tidy( $text ); + // We don't care about where Tidy wants to stick is ps + $text = trim( preg_replace( '#/?p#', '', $text ) ); + // Windows, we love you! + $text = str_replace( \r, '', $text ); + $this-assertEquals( $expected, $text, $msg ); + } + + public function provideTestWrapping() { + return array( + array( + 'mw:editsection page=foo section=barfoo/mw:editsection', + 'mw:editsection page=foo section=barfoo/mw:editsection', + 'mw:editsection should survive tidy' + ), + array( + 'editsection page=foo section=barfoo/editsection', + 'editsection page=foo section=barfoo/editsection', + 'editsection should survive tidy' + ), + array( 'mw:tocfoo/mw:toc', 'mw:tocfoo/mw:toc', 'mw:toc should survive tidy' ), + array( link foo=\bar\ /\nfoo, 'link foo=bar/foo', 'link should survive tidy' ), + array( meta foo=\bar\ /\nfoo, 'meta foo=bar/foo', 'meta should survive tidy' ), + ); + } +} \ No newline at end of file -- To view, visit https://gerrit.wikimedia.org/r/91984 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ibf96cc3bc94fac75fd92ec5b9205011fcb68f0c2 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: REL1_22 Gerrit-Owner: Bartosz Dziewoński matma@gmail.com Gerrit-Reviewer: Bartosz Dziewoński matma@gmail.com Gerrit-Reviewer: MaxSem maxsem.w...@gmail.com Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits