Browse Source

fix getURL (again)

Nicolas Cannasse 14 years ago
parent
commit
ff76517b02
2 changed files with 21 additions and 4 deletions
  1. 10 2
      std/flash/Lib.hx
  2. 11 2
      std/flash9/Lib.hx

+ 10 - 2
std/flash/Lib.hx

@@ -40,8 +40,16 @@ class Lib {
 	}
 	}
 
 
 	public static function getURL( url : String, ?target : String, ?allowScripts ) {
 	public static function getURL( url : String, ?target : String, ?allowScripts ) {
-		if( !allowScripts && url.toLowerCase.substr(0,11) == "javascript:" )
-			throw "Scripts not allowed in URL";
+		if( !allowScripts ) {
+			while( true ) {
+				var c = url.charCodeAt(0);
+				if( c == ' '.code || c == '\n'.code || c == '\r'.code )
+					url = url.substr(1);
+				else break;
+			}
+			if( url.toLowerCase().substr(0,11) == "javascript:" )
+				throw "Scripts not allowed in URL";
+		}
 		untyped __geturl__(url,if( target == null ) "_self" else target);
 		untyped __geturl__(url,if( target == null ) "_self" else target);
 	}
 	}
 
 

+ 11 - 2
std/flash9/Lib.hx

@@ -53,8 +53,17 @@ class Lib {
 	}
 	}
 
 
 	public static function getURL( url : flash.net.URLRequest, ?target : String, ?allowScripts : Bool ) {
 	public static function getURL( url : flash.net.URLRequest, ?target : String, ?allowScripts : Bool ) {
-		if( !allowScripts && url != null && url.url.toLowerCase.substr(0,11) == "javascript:" )
-			throw "Scripts not allowed in URL";
+		if( !allowScripts && url != null ) {
+			var url = url.url;
+			while( true ) {
+				var c = url.charCodeAt(0);
+				if( c == ' '.code || c == '\n'.code || c == '\r'.code )
+					url = url.substr(1);
+				else break;
+			}
+			if( url.toLowerCase().substr(0,11) == "javascript:" )
+				throw "Scripts not allowed in URL";
+		}
 		var f = untyped __global__["flash.net.navigateToURL"];
 		var f = untyped __global__["flash.net.navigateToURL"];
 		if( target == null )
 		if( target == null )
 			f(url);
 			f(url);