SECURITY: Fix extension detection with 2 .'s
authorTim Starling <tstarling@wikimedia.org>
Wed, 14 Aug 2013 16:31:05 +0000 (09:31 -0700)
committerCSteipp <csteipp@wikimedia.org>
Tue, 3 Sep 2013 22:10:31 +0000 (22:10 +0000)
Fix IE6 extension detection, to prevent XSS in the API response.

Bug: 52746
Change-Id: If58a81b62209b36bd143a1766a8a20c9c34dbe3b

includes/libs/IEUrlExtension.php
tests/phpunit/includes/libs/IEUrlExtensionTest.php

index 79387e6..49d05d4 100644 (file)
@@ -232,7 +232,7 @@ class IEUrlExtension {
                        }
                        // We found an illegal character or another dot
                        // Skip to that character and continue the loop
-                       $pos = $nextPos + 1;
+                       $pos = $nextPos;
                        $remainingLength = $urlLength - $pos;
                }
                return false;
index 984907b..d04dd7d 100644 (file)
@@ -115,4 +115,12 @@ class IEUrlExtensionTest extends MediaWikiTestCase {
                        'Dot at end of string'
                );
        }
+
+       function testTwoDots() {
+               $this->assertEquals(
+                       'z',
+                       IEUrlExtension::findIE6Extension( 'x.y.z' ),
+                       'Two dots'
+               );
+       }
 }