EBernhardson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/179007
Change subject: Gracefully handle non-ascii hrefs in redlinker
......................................................................
Gracefully handle non-ascii hrefs in redlinker
Title::newFromText() requires its input to be urldecoded, but the
redlinker was not decoding it before trying to generate the new title.
Fixes T78090
Bug: T78090
Change-Id: I5c79a1aadb65a1499f210265e02f8b04a1691d0f
---
M includes/Parsoid/Fixer/Redlinker.php
M tests/phpunit/Parsoid/Fixer/RedlinkerTest.php
2 files changed, 12 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow
refs/changes/07/179007/1
diff --git a/includes/Parsoid/Fixer/Redlinker.php
b/includes/Parsoid/Fixer/Redlinker.php
index 856607c..fd5e401 100644
--- a/includes/Parsoid/Fixer/Redlinker.php
+++ b/includes/Parsoid/Fixer/Redlinker.php
@@ -69,7 +69,7 @@
// @todo Get proper title in here. doesn't matter currently
due to
// the html from parsoid using '../../' style of relative
// that don't strictly require the title its relative from.
- $title = Utils::createRelativeTitle( $href,
Title::newMainPage() );
+ $title = Utils::createRelativeTitle( urldecode( $href ),
Title::newMainPage() );
if ( $title !== null ) {
$this->batch->addObj( $title );
}
@@ -110,7 +110,7 @@
return;
}
- $title = Utils::createRelativeTitle( $href, $title );
+ $title = Utils::createRelativeTitle( urldecode( $href ), $title
);
if ( $title === null ) {
return;
}
diff --git a/tests/phpunit/Parsoid/Fixer/RedlinkerTest.php
b/tests/phpunit/Parsoid/Fixer/RedlinkerTest.php
index 739a069..de924eb 100644
--- a/tests/phpunit/Parsoid/Fixer/RedlinkerTest.php
+++ b/tests/phpunit/Parsoid/Fixer/RedlinkerTest.php
@@ -43,13 +43,22 @@
),
array(
- 'Link containing UTF-8 content passes through
as UTF-8',
+ 'Link containing UTF-8 anchor content passes
through as UTF-8',
// html from parsoid for: [[Foo|test – test]]
'<a rel="mw:WikiLink" href="./Foo"
data-parsoid=\'{"stx":"piped","a":{"href":"./Foo"},"sa":{"href":"Foo"},"dsr":[0,19,6,2]}\'>test
– test</a>',
// title text from parsoid
// expect string
'test – test',
),
+
+ array(
+ 'Link containing urlencoded UTF-8 href works',
+ // html from parsoid for: [[Viquipèdia:La
taverna/Tecnicismes/Arxius_2]]
+ '<a rel="mw:WikiLink"
href="./Viquip%C3%A8dia:La_taverna/Tecnicismes/Arxius_2" title="Viquipdia:La
taverna/Tecnicismes/Arxius 2"
data-parsoid=\'{"stx":"simple","a":{"href":"./Viquipdia:La_taverna/Tecnicismes/Arxius_2"},"sa":{"href":"Viquipdia:La
taverna/Tecnicismes/Arxius 2"},"dsr":[59,105,2,2]}\'>Viquipdia:La
taverna/Tecnicismes/Arxius 2</a>',
+ // anchor should be transformed to
/wiki/Viquip...
+ // annoyingly we don't control Title::exists()
so just assume redlink
+
'/w/index.php?title=Viquip%C3%A8dia:La_taverna/Tecnicismes/Arxius_2'
+ ),
);
}
--
To view, visit https://gerrit.wikimedia.org/r/179007
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5c79a1aadb65a1499f210265e02f8b04a1691d0f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits