Index: trunk/phase3/tests/parser/parserTests.txt |
— | — | @@ -2227,6 +2227,28 @@ |
2228 | 2228 | !! end |
2229 | 2229 | |
2230 | 2230 | !! test |
| 2231 | +Magic Word: {{PAGENAME}} with metacharacters |
| 2232 | +!! options |
| 2233 | +title=[['foo & bar = baz']] |
| 2234 | +!! input |
| 2235 | +''{{PAGENAME}}'' |
| 2236 | +!! result |
| 2237 | +<p><i>'foo & bar = baz'</i> |
| 2238 | +</p> |
| 2239 | +!! end |
| 2240 | + |
| 2241 | +!! test |
| 2242 | +Magic Word: {{PAGENAME}} with metacharacters (bug 26781) |
| 2243 | +!! options |
| 2244 | +title=[[*RFC 1234 http://example.com/]] |
| 2245 | +!! input |
| 2246 | +{{PAGENAME}} |
| 2247 | +!! result |
| 2248 | +<p>*RFC 1234 http://example.com/ |
| 2249 | +</p> |
| 2250 | +!! end |
| 2251 | + |
| 2252 | +!! test |
2231 | 2253 | Magic Word: {{PAGENAMEE}} |
2232 | 2254 | !! options |
2233 | 2255 | title=[[User:Ævar Arnfjörð Bjarmason]] |
Index: trunk/phase3/includes/GlobalFunctions.php |
— | — | @@ -1149,21 +1149,20 @@ |
1150 | 1150 | * Escapes the given text so that it may be output using addWikiText() |
1151 | 1151 | * without any linking, formatting, etc. making its way through. This |
1152 | 1152 | * is achieved by substituting certain characters with HTML entities. |
1153 | | - * As required by the callers, <nowiki> is not used. It currently does |
1154 | | - * not filter out characters which have special meaning only at the |
1155 | | - * start of a line, such as "*". |
| 1153 | + * As required by the callers, <nowiki> is not used. |
1156 | 1154 | * |
1157 | 1155 | * @param $text String: text to be escaped |
1158 | 1156 | */ |
1159 | 1157 | function wfEscapeWikiText( $text ) { |
1160 | | - $text = str_replace( |
1161 | | - array( '[', '|', ']', '\'', 'ISBN ', |
1162 | | - 'RFC ', '://', "\n=", '{{', '}}' ), |
1163 | | - array( '[', '|', ']', ''', 'ISBN ', |
1164 | | - 'RFC ', '://', "\n=", '{{', '}}' ), |
1165 | | - htmlspecialchars( $text ) |
1166 | | - ); |
1167 | | - return $text; |
| 1158 | + $text = strtr( "\n$text", array( |
| 1159 | + '"' => '"', '&' => '&', "'" => ''', '<' => '<', |
| 1160 | + '=' => '=', '>' => '>', '[' => '[', ']' => ']', |
| 1161 | + '{' => '{', '|' => '|', '}' => '}', |
| 1162 | + "\n#" => "\n#", "\n*" => "\n*", |
| 1163 | + "\n:" => "\n:", "\n;" => "\n;", |
| 1164 | + '://' => '://', 'ISBN ' => 'ISBN ', 'RFC ' => 'RFC ', |
| 1165 | + ) ); |
| 1166 | + return substr( $text, 1 ); |
1168 | 1167 | } |
1169 | 1168 | |
1170 | 1169 | /** |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -98,6 +98,7 @@ |
99 | 99 | * (bug 26449) Keep underlines from headings outside of tables and thumbs by |
100 | 100 | adding overflow:hidden to h1,h2,h3,h4,h5,h6 (also fixes editsection bunching). |
101 | 101 | * (bug 26708) Remove background-color:white from tables in Monobook and Vector. |
| 102 | +* (bug 26781) {{PAGENAME}} and related parser functions escape their output better |
102 | 103 | |
103 | 104 | === API changes in 1.18 === |
104 | 105 | * (bug 26339) Throw warning when truncating an overlarge API result |