User:AnomieBOT/source/tasks/TemplateUnsubstifier.pm: Difference between revisions

Content deleted Content added
AnomieBOT (talk | contribs)
Updating published sources: TemplateUnsubstifier: * Log templates being unsubstified.
AnomieBOT (talk | contribs)
Updating published sources: TemplateUnsubstifier: * Add sanity check to prevent broken edits like [//en.wikipedia.org/w/index.php?diff=prev&oldid=582081088 this] * Another log message.
Line 82:
@templates = @{$self->{'templates'}};
} else {
$api->log( "Loading templates list from Wikipedia:AutoWikiBrowser/Dated templates" );
$res = $api->query(
titles => 'Wikipedia:AutoWikiBrowser/Dated templates',
Line 216 ⟶ 217:
 
# If it doesn't have "unsubst", it's fine to wrap.
returnunless ($txt, $params) unless $txt =~ /unsubst/i; ) {
# sanity-check that the existing template code doesn't break template
# syntax, see https://en.wikipedia.org/w/index.php?diff=prev&oldid=582081088
my $tmp = $api->process_templates( "{{\x02foo\x03|1=$txt}}", sub {
my $name = shift;
my $params = shift;
return undef unless $name eq "\x02foo\x03";
return 'bad' unless @$params == 1;
return 'ok';
} );
return ($txt, $params) if $tmp eq 'ok';
$api->warn( "HELP: $title contains unwrappable content" );
return undef;
}
 
# If it already uses Module:Unsubst, then we don't need to do anything to