User:松/Drafts/Extension:AbuseFilter/Rules format: Difference between revisions
User:松/Drafts/Extension:AbuseFilter/Rules format (view source)
Revision as of 06:11, 1 August 2020
, 3 years agoTranslation code removal
m (459 revisions imported: Per request at the community portal.) |
(Translation code removal) |
||
Line 1:
The rules are formatted much as conditionals in a C/Java/Perl-like language.
== Strings ==
You can specify a literal by placing it in single or double quotes (for strings), or by typing it in as-is (for numbers, both floating-point and integer).
▲You can specify a literal by placing it in single or double quotes (for strings), or by typing it in as-is (for numbers, both floating-point and integer).</translate>
You can get linebreaks with <tvar|1><code>\n</code></>, tab characters with <tvar|2><code>\t</code></>, and you can also escape the quote character with a backslash.▼
▲You can get linebreaks with
Use the <tvar|1><code>+</code></> (plus) symbol to [[w:concatenation|concatenate]] two [[w:string literal|literal strings]] or the values of two [[w:Variable (computer science)|vars]] with a string value.▼
▲Use the
; Examples:
<syntaxhighlight lang="perl">
"
'
'
"
1234
1.234
Line 27 ⟶ 22:
</syntaxhighlight>
▲==User-defined variables== <!--T:11-->
You can define custom variables for ease of understanding with the assign symbol
Such variables may use letters, underscores, and numbers (apart from the first character) and are case-insensitive.
▲You can define custom variables for ease of understanding with the assign symbol <tvar|1><code>:=</code></> in a line (closed by <tvar|2><code>;</code></>) within a condition.</translate>
▲Such variables may use letters, underscores, and numbers (apart from the first character) and are case-insensitive.</translate>
▲Example (from <tvar|1>[[w:Special:AbuseFilter/79]]</>):
<syntaxhighlight lang="c">
Line 49 ⟶ 40:
</syntaxhighlight>
==Arrays==
<!--Note: these examples are also used in https://phabricator.wikimedia.org/diffusion/EABF/browse/master/tests/parserTests/mwexamples-arrays.t -->
AbuseFilter has support for non-associative arrays, which can be used like in the following examples.
▲AbuseFilter has support for non-associative arrays, which can be used like in the following examples.</translate>
{{Caution|1=<translate><!--T:460--> Expressions like <tvar|1><code>page_namespace in [14, 15]</code></> may not work as expected.</translate> <translate><!--T:440--> This one will evaluate to <tvar|1><samp>true</samp></> also if <tvar|2><code>page_namespace</code></> is <tvar|3><samp>1</samp></>, <tvar|4><samp>4</samp></>, or <tvar|5><samp>5</samp></>.</translate> <translate><!--T:441--> For more information and possible workarounds, please see <tvar|1>[[:phab:T181024|T181024]]</>.</translate>}}
|