Changeset 21554
- Timestamp:
- 10/18/08 01:46:14 (5 years ago)
- Location:
- lang/javascript/WindowNameXDomainRequest
- Files:
-
- 5 modified
-
client/s.gif (modified) (1 prop) (previous)
-
client/xd-client.html (modified) (3 diffs, 1 prop)
-
js/xd-client.js (modified) (2 diffs)
-
js/xd-proxy.js (modified) (5 diffs)
-
server/xd-proxy.html (modified) (2 diffs, 1 prop)
Legend:
- Unmodified
- Added
- Removed
-
lang/javascript/WindowNameXDomainRequest/client/s.gif
- Property svn:mime-type changed from application/octet-stream to image/gif
-
lang/javascript/WindowNameXDomainRequest/client/xd-client.html
- Property svn:mime-type changed from text/html to text/html; charset=UTF-8
r21550 r21554 1 1 <html> 2 2 <head> 3 <title>WindowNameXDomainRequest client</title> 3 4 <script type="text/javascript" src="../lib/json2.js"></script> 4 5 <script type="text/javascript" src="../js/xd-client.js"></script> … … 17 18 }, function(response) { 18 19 if (response.status == 200) { 19 alert(response.body) 20 alert(response.body); 20 21 } 21 22 }); … … 25 26 </head> 26 27 <body> 27 <img src="s.gif" />28 <input type="button" onclick="javascript:windowNameXHRTest();" value="window.name XHR Test" />28 <img src="s.gif"> 29 <input type="button" onclick="javascript:windowNameXHRTest();" value="window.name XHR Test"> 29 30 </body> 30 31 </html> -
lang/javascript/WindowNameXDomainRequest/js/xd-client.js
r21550 r21554 1 1 /** 2 * window.name transport によるクロスドメインリクエスト 2 * window.name transport によるクロスドメインリクエスト 3 3 * (クライアント側) 4 4 * … … 49 49 callback.call(scope, res); 50 50 } 51 } catch (e) {}51 } catch (e) {} 52 52 }, 100); 53 53 54 54 } 55 55 56 } 56 }; 57 57 58 58 /** -
lang/javascript/WindowNameXDomainRequest/js/xd-proxy.js
r21543 r21554 1 1 /** 2 * window.name transport によるクロスドメインリクエスト 2 * window.name transport によるクロスドメインリクエスト 3 3 * (プロキシ側) 4 4 * … … 15 15 16 16 // 戻り先のURLを取得 17 m = retUrl.match(/^http(s)?:\/\/([^\/ ]+)/);17 m = retUrl.match(/^http(s)?:\/\/([^\/:]+)\.?/); 18 18 if (!m) return; 19 19 var domain = m[2]; 20 var ssl = !!m[1] 20 var ssl = !!m[1]; 21 21 22 22 // リクエスト情報をパース 23 var request = JSON.parse(window.name) 23 var request = JSON.parse(window.name); 24 24 25 25 // ポリシーのチェック。許可されたドメインからのリクエストか、など … … 53 53 if (xdRequestPolicy.sslRequired && !ssl) return false; 54 54 if (xdRequestPolicy.allowedMethod) { 55 var allowedMethod = new RegExp('^( '+xdRequestPolicy.allowedMethod.replace(/,/g, '|')+')$', 'i');55 var allowedMethod = new RegExp('^(?:'+xdRequestPolicy.allowedMethod.replace(/\s*,\s*/g, '|')+')$', 'i'); 56 56 if (!allowedMethod.test(request.method)) return false; 57 57 } 58 58 if (xdRequestPolicy.allowedDomain) { 59 var allowedDomains = xdRequestPolicy.allowedDomain.split( ',');59 var allowedDomains = xdRequestPolicy.allowedDomain.split(/\s*,\s*/); 60 60 for (var i=0, len=allowedDomains.length; i<len; i++) { 61 var allowedDomain = allowedDomains[i].replace(/ \./g, '\.').replace(/\*/g, '.*');61 var allowedDomain = allowedDomains[i].replace(/(?=\.)/g, '\\').replace(/(?=\*)/g, '.'); 62 62 if (new RegExp('^'+allowedDomain+'$').test(domain)) return true; 63 63 } … … 82 82 status : xhr.status, 83 83 body : xhr.responseText 84 }) 84 }); 85 85 } 86 } 86 }; 87 87 xhr.send(request.body || null); 88 88 } … … 91 91 * 92 92 */ 93 function createXMLHttpRequest() { 93 function createXMLHttpRequest() { 94 94 if (window.XMLHttpRequest) { 95 95 return new XMLHttpRequest(); 96 96 } else if (window.ActiveXObject) { 97 97 try { 98 return new ActiveXObject( "Msxml2.XMLHTTP");99 } catch (e) {100 return new ActiveXObject( "Microsoft.XMLHTTP");98 return new ActiveXObject('Msxml2.XMLHTTP'); 99 } catch (e) { 100 return new ActiveXObject('Microsoft.XMLHTTP'); 101 101 } 102 102 } 103 103 } 104 104 -
lang/javascript/WindowNameXDomainRequest/server/xd-proxy.html
- Property svn:mime-type changed from text/html to text/html; charset=UTF-8
r21548 r21554 1 1 <html> 2 2 <head> 3 <title>WindowNameXDomainRequest proxy</title> 3 4 <script type="text/javascript" src="../lib/json2.js"></script> 4 5 <script type="text/javascript"> … … 6 7 allowedRequest : 'GET,POST', 7 8 allowedDomain : '*' 8 } 9 }; 9 10 </script> 10 11 <script type="text/javascript" src="../js/xd-proxy.js"></script>
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)