Require tags to be valid page titles. In the message, gives general recommendations that they be short and simple, rather than specifying the exact criteria. I want to encourage simplicity in tags, rather than fixing an immediate problem

This commit is contained in:
Andrew Garrett 2009-07-17 15:37:03 +00:00
parent d69a31acb3
commit 94a9b2b174
2 changed files with 22 additions and 0 deletions

View file

@ -216,6 +216,8 @@ Please ask a user with permission to add restricted actions to make the change f
'abusefilter-edit-export' => 'Export this filter to another wiki',
'abusefilter-edit-syntaxok' => 'No syntax errors detected.',
'abusefilter-edit-syntaxerr' => 'Syntax error detected: $1',
'abusefilter-edit-bad-tags' => 'One or more of the tags you specified is not valid.
Tags should be short, and they should not contain special characters.',
// Filter editing helpers
'abusefilter-edit-builder-select' => 'Select an option to add it at the cursor',

View file

@ -73,6 +73,26 @@ class AbuseFilterViewEdit extends AbuseFilterView {
);
return;
}
// 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;
}
if ($bad) {
$wgOut->addHTML( $this->buildFilterEditor(
wfMsgExt( 'abusefilter-edit-bad-tags', 'parse' ),
$this->mFilter,
$history_id
) );
return;
}
}
}
$newRow = get_object_vars($newRow); // Convert from object to array