Anomie has uploaded a new change for review.
https://gerrit.wikimedia.org/r/197315
Change subject: Improve tag name validation
......................................................................
Improve tag name validation
Various pieces of the tagging system will break if the tag name contains
slashes or commas, so that should be checked for.
MediaWiki core (as of Ic5d75432) contains a method for doing just that,
so use it if possible.
Bug: T92956
Bug: T27151
Change-Id: Ibc3095879f276a5436362f471b885e64f338522e
---
M Views/AbuseFilterViewEdit.php
1 file changed, 15 insertions(+), 6 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/AbuseFilter
refs/changes/15/197315/1
diff --git a/Views/AbuseFilterViewEdit.php b/Views/AbuseFilterViewEdit.php
index 20fdc26..f8ec7af 100644
--- a/Views/AbuseFilterViewEdit.php
+++ b/Views/AbuseFilterViewEdit.php
@@ -106,17 +106,26 @@
// If we've activated the 'tag' option, check the
arguments for validity.
if ( !empty( $actions['tag'] ) ) {
- $bad = false;
foreach ( $actions['tag']['parameters'] as $tag
) {
- $t = Title::makeTitleSafe(
NS_MEDIAWIKI, 'tag-' . $tag );
- if ( !$t ) {
- $bad = true;
+ /// @todo When older versions of
MediaWiki are no longer
+ /// supported, remove the check and BC
code.
+ if ( is_callable(
'ChangeTags::isTagNameValid' ) ) {
+ $status =
ChangeTags::isTagNameValid( $tag );
+ } else {
+ // BC
+ if ( strpos( $tag, ',' ) !==
false || strpos( $tag, '/' ) !== false ||
+ !Title::makeTitleSafe(
NS_MEDIAWIKI, "tag-{$tag}-description" )
+ ) {
+ $status =
Status::newFatal( 'abusefilter-edit-bad-tags' );
+ } else {
+ $status =
Status::newGood();
+ }
}
- if ( $bad ) {
+ if ( !$status->isGood() ) {
$out->addHTML(
$this->buildFilterEditor(
- $this->msg(
'abusefilter-edit-bad-tags' )->parseAsBlock(),
+
$status->getMessage()->parseAsBlock(),
$this->mFilter,
$history_id
)
--
To view, visit https://gerrit.wikimedia.org/r/197315
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibc3095879f276a5436362f471b885e64f338522e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/AbuseFilter
Gerrit-Branch: master
Gerrit-Owner: Anomie <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits