MediaWiki  1.23.15
UploadBaseTest.php
Go to the documentation of this file.
1 <?php
2 
6 class UploadBaseTest extends MediaWikiTestCase {
7 
9  protected $upload;
10 
11  protected function setUp() {
13  parent::setUp();
14 
15  $this->upload = new UploadTestHandler;
16  $this->hooks = $wgHooks;
17  $wgHooks['InterwikiLoadPrefix'][] = function ( $prefix, &$data ) {
18  return false;
19  };
20  }
21 
22  protected function tearDown() {
24  $wgHooks = $this->hooks;
25 
26  parent::tearDown();
27  }
28 
36  public function testTitleValidation( $srcFilename, $dstFilename, $code, $msg ) {
37  /* Check the result code */
38  $this->assertEquals( $code,
39  $this->upload->testTitleValidation( $srcFilename ),
40  "$msg code" );
41 
42  /* If we expect a valid title, check the title itself. */
43  if ( $code == UploadBase::OK ) {
44  $this->assertEquals( $dstFilename,
45  $this->upload->getTitle()->getText(),
46  "$msg text" );
47  }
48  }
49 
53  public static function provideTestTitleValidation() {
54  return array(
55  /* Test a valid title */
56  array( 'ValidTitle.jpg', 'ValidTitle.jpg', UploadBase::OK,
57  'upload valid title' ),
58  /* A title with a slash */
59  array( 'A/B.jpg', 'B.jpg', UploadBase::OK,
60  'upload title with slash' ),
61  /* A title with illegal char */
62  array( 'A:B.jpg', 'A-B.jpg', UploadBase::OK,
63  'upload title with colon' ),
64  /* Stripping leading File: prefix */
65  array( 'File:C.jpg', 'C.jpg', UploadBase::OK,
66  'upload title with File prefix' ),
67  /* Test illegal suggested title (r94601) */
68  array( '%281%29.JPG', null, UploadBase::ILLEGAL_FILENAME,
69  'illegal title for upload' ),
70  /* A title without extension */
71  array( 'A', null, UploadBase::FILETYPE_MISSING,
72  'upload title without extension' ),
73  /* A title with no basename */
74  array( '.jpg', null, UploadBase::MIN_LENGTH_PARTNAME,
75  'upload title without basename' ),
76  /* A title that is longer than 255 bytes */
77  array( str_repeat( 'a', 255 ) . '.jpg', null, UploadBase::FILENAME_TOO_LONG,
78  'upload title longer than 255 bytes' ),
79  /* A title that is longer than 240 bytes */
80  array( str_repeat( 'a', 240 ) . '.jpg', null, UploadBase::FILENAME_TOO_LONG,
81  'upload title longer than 240 bytes' ),
82  );
83  }
84 
89  public function testVerifyUpload() {
90  /* Setup with zero file size */
91  $this->upload->initializePathInfo( '', '', 0 );
92  $result = $this->upload->verifyUpload();
93  $this->assertEquals( UploadBase::EMPTY_FILE,
94  $result['status'],
95  'upload empty file' );
96  }
97 
98  // Helper used to create an empty file of size $size.
99  private function createFileOfSize( $size ) {
100  $filename = tempnam( wfTempDir(), "mwuploadtest" );
101 
102  $fh = fopen( $filename, 'w' );
103  ftruncate( $fh, $size );
104  fclose( $fh );
105 
106  return $filename;
107  }
108 
114  public function testMaxUploadSize() {
115  global $wgMaxUploadSize;
116  $savedGlobal = $wgMaxUploadSize; // save global
118  $wgFileExtensions[] = 'txt';
119 
120  $wgMaxUploadSize = 100;
121 
122  $filename = $this->createFileOfSize( $wgMaxUploadSize );
123  $this->upload->initializePathInfo( basename( $filename ) . '.txt', $filename, 100 );
124  $result = $this->upload->verifyUpload();
125  unlink( $filename );
126 
127  $this->assertEquals(
128  array( 'status' => UploadBase::OK ), $result );
129 
130  $wgMaxUploadSize = $savedGlobal; // restore global
131  }
132 
133 
137  public function testCheckSvgScriptCallback( $svg, $wellFormed, $filterMatch, $message ) {
138  list( $formed, $match ) = $this->upload->checkSvgString( $svg );
139  $this->assertSame( $wellFormed, $formed, $message );
140  $this->assertSame( $filterMatch, $match, $message );
141  }
142 
143  public static function provideCheckSvgScriptCallback() {
144  return array(
145  // html5sec SVG vectors
146  array(
147  '<svg xmlns="http://www.w3.org/2000/svg"><script>alert(1)</script></svg>',
148  true,
149  true,
150  'Script tag in svg (http://html5sec.org/#47)'
151  ),
152  array(
153  '<svg xmlns="http://www.w3.org/2000/svg"><g onload="javascript:alert(1)"></g></svg>',
154  true,
155  true,
156  'SVG with onload property (http://html5sec.org/#11)'
157  ),
158  array(
159  '<svg onload="javascript:alert(1)" xmlns="http://www.w3.org/2000/svg"></svg>',
160  true,
161  true,
162  'SVG with onload property (http://html5sec.org/#65)'
163  ),
164  array(
165  '<svg xmlns="http://www.w3.org/2000/svg"> <a xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="javascript:alert(1)"><rect width="1000" height="1000" fill="white"/></a> </svg>',
166  true,
167  true,
168  'SVG with javascript xlink (http://html5sec.org/#87)'
169  ),
170  array(
171  '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><use xlink:href="data:application/xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KPGRlZnM+CjxjaXJjbGUgaWQ9InRlc3QiIHI9IjUwIiBjeD0iMTAwIiBjeT0iMTAwIiBzdHlsZT0iZmlsbDogI0YwMCI+CjxzZXQgYXR0cmlidXRlTmFtZT0iZmlsbCIgYXR0cmlidXRlVHlwZT0iQ1NTIiBvbmJlZ2luPSdhbGVydChkb2N1bWVudC5jb29raWUpJwpvbmVuZD0nYWxlcnQoIm9uZW5kIiknIHRvPSIjMDBGIiBiZWdpbj0iMXMiIGR1cj0iNXMiIC8+CjwvY2lyY2xlPgo8L2RlZnM+Cjx1c2UgeGxpbms6aHJlZj0iI3Rlc3QiLz4KPC9zdmc+#test"/> </svg>',
172  true,
173  true,
174  'SVG with Opera image xlink (http://html5sec.org/#88 - c)'
175  ),
176  array(
177  '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <animation xlink:href="javascript:alert(1)"/> </svg>',
178  true,
179  true,
180  'SVG with Opera animation xlink (http://html5sec.org/#88 - a)'
181  ),
182  array(
183  '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <animation xlink:href="data:text/xml,%3Csvg xmlns=\'http://www.w3.org/2000/svg\' onload=\'alert(1)\'%3E%3C/svg%3E"/> </svg>',
184  true,
185  true,
186  'SVG with Opera animation xlink (http://html5sec.org/#88 - b)'
187  ),
188  array(
189  '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <image xlink:href="data:image/svg+xml,%3Csvg xmlns=\'http://www.w3.org/2000/svg\' onload=\'alert(1)\'%3E%3C/svg%3E"/> </svg>',
190  true,
191  true,
192  'SVG with Opera image xlink (http://html5sec.org/#88 - c)'
193  ),
194  array(
195  '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <foreignObject xlink:href="javascript:alert(1)"/> </svg>',
196  true,
197  true,
198  'SVG with Opera foreignObject xlink (http://html5sec.org/#88 - d)'
199  ),
200  array(
201  '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <foreignObject xlink:href="data:text/xml,%3Cscript xmlns=\'http://www.w3.org/1999/xhtml\'%3Ealert(1)%3C/script%3E"/> </svg>',
202  true,
203  true,
204  'SVG with Opera foreignObject xlink (http://html5sec.org/#88 - e)'
205  ),
206  array(
207  '<svg xmlns="http://www.w3.org/2000/svg"> <set attributeName="onmouseover" to="alert(1)"/> </svg>',
208  true,
209  true,
210  'SVG with event handler set (http://html5sec.org/#89 - a)'
211  ),
212  array(
213  '<svg xmlns="http://www.w3.org/2000/svg"> <animate attributeName="onunload" to="alert(1)"/> </svg>',
214  true,
215  true,
216  'SVG with event handler animate (http://html5sec.org/#89 - a)'
217  ),
218  array(
219  '<svg xmlns="http://www.w3.org/2000/svg"> <handler xmlns:ev="http://www.w3.org/2001/xml-events" ev:event="load">alert(1)</handler> </svg>',
220  true,
221  true,
222  'SVG with element handler (http://html5sec.org/#94)'
223  ),
224  array(
225  '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <feImage> <set attributeName="xlink:href" to="data:image/svg+xml;charset=utf-8;base64, PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxzY3JpcHQ%2BYWxlcnQoMSk8L3NjcmlwdD48L3N2Zz4NCg%3D%3D"/> </feImage> </svg>',
226  true,
227  true,
228  'SVG with href to data: url (http://html5sec.org/#95)'
229  ),
230  array(
231  '<svg xmlns="http://www.w3.org/2000/svg" id="foo"> <x xmlns="http://www.w3.org/2001/xml-events" event="load" observer="foo" handler="data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%0A%3Chandler%20xml%3Aid%3D%22bar%22%20type%3D%22application%2Fecmascript%22%3E alert(1) %3C%2Fhandler%3E%0A%3C%2Fsvg%3E%0A#bar"/> </svg>',
232  true,
233  true,
234  'SVG with Tiny handler (http://html5sec.org/#104)'
235  ),
236  array(
237  '<svg xmlns="http://www.w3.org/2000/svg"> <a id="x"><rect fill="white" width="1000" height="1000"/></a> <rect fill="white" style="clip-path:url(test3.svg#a);fill:url(#b);filter:url(#c);marker:url(#d);mask:url(#e);stroke:url(#f);"/> </svg>',
238  true,
239  true,
240  'SVG with new CSS styles properties (http://html5sec.org/#109)'
241  ),
242  array(
243  '<svg xmlns="http://www.w3.org/2000/svg"> <a id="x"><rect fill="white" width="1000" height="1000"/></a> <rect clip-path="url(test3.svg#a)" /> </svg>',
244  true,
245  true,
246  'SVG with new CSS styles properties as attributes'
247  ),
248  array(
249  '<svg xmlns="http://www.w3.org/2000/svg"> <a id="x"> <rect fill="white" width="1000" height="1000"/> </a> <rect fill="url(http://html5sec.org/test3.svg#a)" /> </svg>',
250  true,
251  true,
252  'SVG with new CSS styles properties as attributes (2)'
253  ),
254  array(
255  '<svg xmlns="http://www.w3.org/2000/svg"> <path d="M0,0" style="marker-start:url(test4.svg#a)"/> </svg>',
256  true,
257  true,
258  'SVG with path marker-start (http://html5sec.org/#110)'
259  ),
260  array(
261  '<?xml version="1.0"?> <?xml-stylesheet type="text/xml" href="#stylesheet"?> <!DOCTYPE doc [ <!ATTLIST xsl:stylesheet id ID #REQUIRED>]> <svg xmlns="http://www.w3.org/2000/svg"> <xsl:stylesheet id="stylesheet" version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <iframe xmlns="http://www.w3.org/1999/xhtml" src="javascript:alert(1)"></iframe> </xsl:template> </xsl:stylesheet> <circle fill="red" r="40"></circle> </svg>',
262  true,
263  true,
264  'SVG with embedded stylesheet (http://html5sec.org/#125)'
265  ),
266  array(
267  '<svg xmlns="http://www.w3.org/2000/svg" id="x"> <listener event="load" handler="#y" xmlns="http://www.w3.org/2001/xml-events" observer="x"/> <handler id="y">alert(1)</handler> </svg>',
268  true,
269  true,
270  'SVG with handler attribute (http://html5sec.org/#127)'
271  ),
272  array(
273  // Haven't found a browser that accepts this particular example, but we
274  // don't want to allow embeded svgs, ever
275  '<svg> <image style=\'filter:url("data:image/svg+xml;charset=utf-8;base64, PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxzY3JpcHQ/YWxlcnQoMSk8L3NjcmlwdD48L3N2Zz4NCg==")\' /> </svg>',
276  true,
277  true,
278  'SVG with image filter via style (http://html5sec.org/#129)'
279  ),
280  array(
281  // This doesn't seem possible without embedding the svg, but just in case
282  '<svg> <a xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="?"> <circle r="400"></circle> <animate attributeName="xlink:href" begin="0" from="javascript:alert(1)" to="" /> </a></svg>',
283  true,
284  true,
285  'SVG with animate from (http://html5sec.org/#137)'
286  ),
287  array(
288  '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <a><text y="1em">Click me</text> <animate attributeName="xlink:href" values="javascript:alert(\'Bang!\')" begin="0s" dur="0.1s" fill="freeze" /> </a></svg>',
289  true,
290  true,
291  'SVG with animate xlink:href (http://html5sec.org/#137)'
292  ),
293  array(
294  '<svg xmlns="http://www.w3.org/2000/svg" xmlns:y="http://www.w3.org/1999/xlink"> <a y:href="#"> <text y="1em">Click me</text> <animate attributeName="y:href" values="javascript:alert(\'Bang!\')" begin="0s" dur="0.1s" fill="freeze" /> </a> </svg>',
295  true,
296  true,
297  'SVG with animate y:href (http://html5sec.org/#137)'
298  ),
299 
300  // Other hostile SVG's
301  array(
302  '<?xml version="1.0" encoding="UTF-8" standalone="no"?> <svg xmlns:xlink="http://www.w3.org/1999/xlink"> <image xlink:href="https://upload.wikimedia.org/wikipedia/commons/3/34/Bahnstrecke_Zeitz-Camburg_1930.png" /> </svg>',
303  true,
304  true,
305  'SVG with non-local image href (bug 65839)'
306  ),
307  array(
308  '<?xml version="1.0" ?> <?xml-stylesheet type="text/xsl" href="/w/index.php?title=User:Jeeves/test.xsl&amp;action=raw&amp;format=xml" ?> <svg> <height>50</height> <width>100</width> </svg>',
309  true,
310  true,
311  'SVG with remote stylesheet (bug 57550)'
312  ),
313  array(
314  '<svg xmlns="http://www.w3.org/2000/svg" viewbox="-1 -1 15 15"> <rect y="0" height="13" width="12" stroke="#179" rx="1" fill="#2ac"/> <text x="1.5" y="11" font-family="courier" stroke="white" font-size="16"><![CDATA[B]]></text> <iframe xmlns="http://www.w3.org/1999/xhtml" srcdoc="&#x3C;&#x73;&#x63;&#x72;&#x69;&#x70;&#x74;&#x3E;&#x61;&#x6C;&#x65;&#x72;&#x74;&#x28;&#x27;&#x58;&#x53;&#x53;&#x45;&#x44;&#x20;&#x3D;&#x3E;&#x20;&#x44;&#x6F;&#x6D;&#x61;&#x69;&#x6E;&#x28;&#x27;&#x2B;&#x74;&#x6F;&#x70;&#x2E;&#x64;&#x6F;&#x63;&#x75;&#x6D;&#x65;&#x6E;&#x74;&#x2E;&#x64;&#x6F;&#x6D;&#x61;&#x69;&#x6E;&#x2B;&#x27;&#x29;&#x27;&#x29;&#x3B;&#x3C;&#x2F;&#x73;&#x63;&#x72;&#x69;&#x70;&#x74;&#x3E;"></iframe> </svg>',
315  true,
316  true,
317  'SVG with rembeded iframe (bug 60771)'
318  ),
319  array(
320  '<svg xmlns="http://www.w3.org/2000/svg" viewBox="6 3 177 153" xmlns:xlink="http://www.w3.org/1999/xlink"> <style>@import url("https://fonts.googleapis.com/css?family=Bitter:700&amp;text=WebPlatform.org");</style> <g transform="translate(-.5,-.5)"> <text fill="#474747" x="95" y="150" text-anchor="middle" font-family="Bitter" font-size="20" font-weight="bold">WebPlatform.org</text> </g> </svg>',
321  true,
322  true,
323  'SVG with @import in style element (bug 69008)'
324  ),
325  array(
326  '<svg xmlns="http://www.w3.org/2000/svg" viewBox="6 3 177 153" xmlns:xlink="http://www.w3.org/1999/xlink"> <style>@import url("https://fonts.googleapis.com/css?family=Bitter:700&amp;text=WebPlatform.org");<foo/></style> <g transform="translate(-.5,-.5)"> <text fill="#474747" x="95" y="150" text-anchor="middle" font-family="Bitter" font-size="20" font-weight="bold">WebPlatform.org</text> </g> </svg>',
327  true,
328  true,
329  'SVG with @import in style element and child element (bug 69008#c11)'
330  ),
331  array(
332  '<svg xmlns="http://www.w3.org/2000/svg" viewBox="6 3 177 153" xmlns:xlink="http://www.w3.org/1999/xlink"> <style>@imporT "https://fonts.googleapis.com/css?family=Bitter:700&amp;text=WebPlatform.org";</style> <g transform="translate(-.5,-.5)"> <text fill="#474747" x="95" y="150" text-anchor="middle" font-family="Bitter" font-size="20" font-weight="bold">WebPlatform.org</text> </g> </svg>',
333  true,
334  true,
335  'SVG with case-insensitive @import in style element (bug T85349)'
336  ),
337  array(
338  '<svg xmlns="http://www.w3.org/2000/svg"> <rect width="100" height="100" style="background-image:url(https://www.google.com/images/srpr/logo11w.png)"/> </svg>',
339  true,
340  true,
341  'SVG with remote background image (bug 69008)'
342  ),
343  array(
344  '<svg xmlns="http://www.w3.org/2000/svg"> <rect width="100" height="100" style="background-image:\55rl(https://www.google.com/images/srpr/logo11w.png)"/> </svg>',
345  true,
346  true,
347  'SVG with remote background image, encoded (bug 69008)'
348  ),
349  array(
350  '<svg xmlns="http://www.w3.org/2000/svg"> <style> #a { background-image:\55rl(\'https://www.google.com/images/srpr/logo11w.png\'); } </style> <rect width="100" height="100" id="a"/> </svg>',
351  true,
352  true,
353  'SVG with remote background image, in style element (bug 69008)'
354  ),
355  array(
356  // This currently doesn't seem to work in any browsers, but in case
357  // http://www.w3.org/TR/css3-images/ is implemented for SVG files
358  '<svg xmlns="http://www.w3.org/2000/svg"> <rect width="100" height="100" style="background-image:image(\'sprites.svg#xywh=40,0,20,20\')"/> </svg>',
359  true,
360  true,
361  'SVG with remote background image using image() (bug 69008)'
362  ),
363  array(
364  // As reported by Cure53
365  '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <a xlink:href="data:text/html;charset=utf-8;base64, PHNjcmlwdD5hbGVydChkb2N1bWVudC5kb21haW4pPC9zY3JpcHQ%2BDQo%3D"> <circle r="400" fill="red"></circle> </a> </svg>',
366  true,
367  true,
368  'SVG with data:text/html link target (firefox only)'
369  ),
370  array(
371  '<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [ <!ENTITY lol "lol"> <!ENTITY lol2 "&#x3C;&#x73;&#x63;&#x72;&#x69;&#x70;&#x74;&#x3E;&#x61;&#x6C;&#x65;&#x72;&#x74;&#x28;&#x27;&#x58;&#x53;&#x53;&#x45;&#x44;&#x20;&#x3D;&#x3E;&#x20;&#x27;&#x2B;&#x64;&#x6F;&#x63;&#x75;&#x6D;&#x65;&#x6E;&#x74;&#x2E;&#x64;&#x6F;&#x6D;&#x61;&#x69;&#x6E;&#x29;&#x3B;&#x3C;&#x2F;&#x73;&#x63;&#x72;&#x69;&#x70;&#x74;&#x3E;"> ]> <svg xmlns="http://www.w3.org/2000/svg" width="68" height="68" viewBox="-34 -34 68 68" version="1.1"> <circle cx="0" cy="0" r="24" fill="#c8c8c8"/> <text x="0" y="0" fill="black">&lol2;</text> </svg>',
372  true,
373  true,
374  'SVG with encoded script tag in internal entity (reported by Beyond Security)'
375  ),
376  array(
377  '<?xml version="1.0"?> <!DOCTYPE svg [ <!ENTITY foo SYSTEM "file:///etc/passwd"> ]> <svg xmlns="http://www.w3.org/2000/svg" version="1.1"> <desc>&foo;</desc> <rect width="300" height="100" style="fill:rgb(0,0,255);stroke-width:1;stroke:rgb(0,0,2)" /> </svg>',
378  false,
379  false,
380  'SVG with external entity'
381  ),
382  array(
383  "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"> <g> <a xlink:href=\"javascript:alert('1&#10;https://google.com')\"> <rect width=\"300\" height=\"100\" style=\"fill:rgb(0,0,255);stroke-width:1;stroke:rgb(0,0,2)\" /> </a> </g> </svg>",
384  true,
385  true,
386  'SVG with javascript <a> link with newline (T122653)'
387  ),
388 
389  // Test good, but strange files that we want to allow
390  array(
391  '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <g> <a xlink:href="http://en.wikipedia.org/wiki/Main_Page"> <path transform="translate(0,496)" id="path6706" d="m 112.09375,107.6875 -5.0625,3.625 -4.3125,5.03125 -0.46875,0.5 -4.09375,3.34375 -9.125,5.28125 -8.625,-3.375 z" style="fill:#cccccc;fill-opacity:1;stroke:#6e6e6e;stroke-width:0.69999999;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;display:inline" /> </a> </g> </svg>',
392  true,
393  false,
394  'SVG with <a> link to a remote site'
395  ),
396  array(
397  '<svg> <defs> <filter id="filter6226" x="-0.93243687" width="2.8648737" y="-0.24250539" height="1.4850108"> <feGaussianBlur stdDeviation="3.2344681" id="feGaussianBlur6228" /> </filter> <clipPath id="clipPath2436"> <path d="M 0,0 L 0,0 L 0,0 L 0,0 z" id="path2438" /> </clipPath> </defs> <g clip-path="url(#clipPath2436)" id="g2460"> <text id="text2466"> <tspan>12345</tspan> </text> </g> <path style="fill:#346733;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:bevel;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:1, 1;stroke-dashoffset:0;filter:url(\'#filter6226\');fill-opacity:1;opacity:0.79807692" d="M 236.82371,332.63732 C 236.92217,332.63732 z" id="path5618" /> </svg>',
398  true,
399  false,
400  'SVG with local urls, including filter: in style'
401  ),
402  );
403  }
404 }
405 
406 class UploadTestHandler extends UploadBase {
407  public function initializeFromRequest( &$request ) {
408  }
409 
410  public function testTitleValidation( $name ) {
411  $this->mTitle = false;
412  $this->mDesiredDestName = $name;
413  $this->mTitleError = UploadBase::OK;
414  $this->getTitle();
415 
416  return $this->mTitleError;
417  }
418 
424  public function checkSvgString( $svg ) {
425  $check = new XmlTypeCheck(
426  $svg,
427  array( $this, 'checkSvgScriptCallback' ),
428  false,
429  array( 'processing_instruction_handler' => 'UploadBase::checkSvgPICallback' )
430  );
431  return array( $check->wellFormed, $check->filterMatch );
432  }
433 }
$result
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. $reader:XMLReader object $logInfo:Array of information Return false to stop further processing of the tag 'ImportHandlePageXMLTag':When parsing a XML tag in a page. $reader:XMLReader object $pageInfo:Array of information Return false to stop further processing of the tag 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information Return false to stop further processing of the tag 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. $reader:XMLReader object Return false to stop further processing of the tag 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. $reader:XMLReader object $revisionInfo:Array of information Return false to stop further processing of the tag 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. $title:Title object for the current page $request:WebRequest $ignoreRedirect:boolean to skip redirect check $target:Title/string of redirect target $article:Article object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) $article:article(object) being checked 'IsTrustedProxy':Override the result of wfIsTrustedProxy() $ip:IP being check $result:Change this value to override the result of wfIsTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of User::isValidEmailAddr(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetMagic':DEPRECATED, use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetSpecialPageAliases':DEPRECATED, use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Associative array mapping language codes to prefixed links of the form "language:title". & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LinkBegin':Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
Definition: hooks.txt:1528
$request
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled also a ContextSource error or success you ll probably need to make sure the header is varied on WebRequest $request
Definition: hooks.txt:1961
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
$wgHooks
$wgHooks['ArticleShow'][]
Definition: hooks.txt:110
hooks
Using a hook running we can avoid having all this option specific stuff in our mainline code Using hooks
Definition: hooks.txt:73
MediaWikiTestCase
Definition: MediaWikiTestCase.php:6
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
$wgFileExtensions
if(! $wgHtml5Version && $wgAllowRdfaAttributes) $wgFileExtensions
Definition: Setup.php:369
list
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition: deferred.txt:11
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:336
$size
$size
Definition: RandomTest.php:75
XmlTypeCheck
Definition: XmlTypeCheck.php:28
$upload
usually copyright or history_copyright This message must be in HTML not wikitext $subpages will be ignored and the rest of subPageSubtitle() will run. 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink' whether MediaWiki currently thinks this is a CSS JS page Hooks may change this value to override the return value of Title::isCssOrJsPage(). 'TitleIsAlwaysKnown' whether MediaWiki currently thinks this page is known isMovable() always returns false. $title whether MediaWiki currently thinks this page is movable Hooks may change this value to override the return value of Title::isMovable(). 'TitleIsWikitextPage' whether MediaWiki currently thinks this is a wikitext page Hooks may change this value to override the return value of Title::isWikitextPage() 'TitleMove' use UploadVerification and UploadVerifyFile instead where the first element is the message key and the remaining elements are used as parameters to the message based on mime etc Preferred in most cases over UploadVerification object $upload
Definition: hooks.txt:2584
MediaWikiTestCase\setUp
setUp()
Definition: MediaWikiTestCase.php:187
wfTempDir
wfTempDir()
Tries to get the system directory for temporary files.
Definition: GlobalFunctions.php:2611
MediaWikiTestCase\tearDown
tearDown()
Definition: MediaWikiTestCase.php:216