Index: trunk/extensions/ParserFunctions/ParserFunctions_body.php |
— | — | @@ -321,6 +321,9 @@ |
322 | 322 | function ifexistCommon( &$parser, $frame, $titletext = '', $then = '', $else = '' ) { |
323 | 323 | global $wgContLang; |
324 | 324 | $title = Title::newFromText( $titletext ); |
| 325 | + if( is_null( $title ) ) # It my be urlencoded (bug 14779) |
| 326 | + $title = Title::newFromUrl( urldecode( $titletext ) ); |
| 327 | + |
325 | 328 | $wgContLang->findVariantLink( $titletext, $title, true ); |
326 | 329 | if ( $title ) { |
327 | 330 | if( $title->getNamespace() == NS_MEDIA ) { |
Index: trunk/extensions/ParserFunctions/funcsParserTests.txt |
— | — | @@ -6,6 +6,12 @@ |
7 | 7 | |
8 | 8 | # fixme: #time seems to be accepting input as local time, which strikes me as wrong |
9 | 9 | |
| 10 | +!! article |
| 11 | +File:Dionysos-Brunnen am Kölner Dom.jpg |
| 12 | +!! text |
| 13 | +blah blah |
| 14 | +!! endarticle |
| 15 | + |
10 | 16 | !! test |
11 | 17 | Input times should probably be UTC, not local time |
12 | 18 | !! input |
— | — | @@ -52,3 +58,34 @@ |
53 | 59 | <DEF> |
54 | 60 | </p> |
55 | 61 | !! end |
| 62 | + |
| 63 | +!! test |
| 64 | +{{#ifexist}} |
| 65 | +!! input |
| 66 | +{{#ifexist:Media:Foobar.jpg|Found|Not found}} |
| 67 | +{{#ifexist:Main Page|Found|Not found}} |
| 68 | +{{#ifexist:Missing|Found|Not found}} |
| 69 | +!! result |
| 70 | +<p>Found |
| 71 | +Found |
| 72 | +Not found |
| 73 | +</p> |
| 74 | +!! end |
| 75 | + |
| 76 | +!! test |
| 77 | +Bug 14779 - {{#ifexist}} does not recognise URL encoded filenames |
| 78 | +Based on http://test.wikipedia.org/wiki/User:Raymond/ifexist |
| 79 | +!! input |
| 80 | +{{#ifexist:Media:F%6fobar.jpg|found|not found}} |
| 81 | +[[:File:Dionysos-Brunnen am Kölner Dom.jpg]] |
| 82 | +{{#ifexist:File:Dionysos-Brunnen am Kölner Dom.jpg|found|not found}} |
| 83 | +[[:File:Dionysos-Brunnen_am_K%C3%B6lner_Dom.jpg]] |
| 84 | +{{#ifexist:File:Dionysos-Brunnen_am_K%C3%B6lner_Dom.jpg|found|not found}} |
| 85 | +!! result |
| 86 | +<p>found |
| 87 | +<a href="https://www.mediawiki.org/wiki/File:Dionysos-Brunnen_am_K%C3%B6lner_Dom.jpg" title="File:Dionysos-Brunnen am Kölner Dom.jpg">File:Dionysos-Brunnen am Kölner Dom.jpg</a> |
| 88 | +found |
| 89 | +<a href="https://www.mediawiki.org/wiki/File:Dionysos-Brunnen_am_K%C3%B6lner_Dom.jpg" title="File:Dionysos-Brunnen am Kölner Dom.jpg">File:Dionysos-Brunnen_am_Kölner_Dom.jpg</a> |
| 90 | +found |
| 91 | +</p> |
| 92 | +!! end |