From 0969d6195fc86dcba304e027cd4b17d9754c27a4 Mon Sep 17 00:00:00 2001 From: Marco Fabbri Date: Fri, 31 Oct 2008 15:04:17 +0000 Subject: [PATCH] Fixed missing starting '^' in regular expression testing for urls sanity (i.e. http, https, webdav, ftp); Added missing files from previous commit, specifically modified DomHelper to take into account of malicious JavaScript injections and XSS. --- index.html | 14 +- index_debug.html | 2 +- js/src/Bookmarklet.js | 372 +++++++++++++++ js/src/Bookmarklet_IE.js | 23 + js/src/Clipperz/PM/BookmarkletProcessor.js | 2 +- .../RecordDetail/FieldValueComponent.js | 2 +- js/src/Clipperz/PM/DataModel/DirectLogin.js | 8 +- js/src/Clipperz/YUI/DomHelper.js | 442 ++++++++++++++++++ 8 files changed, 851 insertions(+), 14 deletions(-) create mode 100644 js/src/Bookmarklet.js create mode 100644 js/src/Bookmarklet_IE.js create mode 100644 js/src/Clipperz/YUI/DomHelper.js diff --git a/index.html b/index.html index 7cffeb4..fab326c 100644 --- a/index.html +++ b/index.html @@ -31005,7 +31005,7 @@

loading ...

case "URL": var _772; _772=Clipperz.Base.sanitizeString(this.value()); -if(!(/(https?|ftp|svn):\/\//.test(_772))){ +if(!(/^(https?|ftp|svn):\/\//.test(_772))){ _772="http://"+_772; } Clipperz.YUI.DomHelper.append(this.element().dom,{tag:"a",href:_772,html:this.value(),target:"_blank"}); @@ -35036,7 +35036,7 @@

loading ...

if(this._hostname==null){ var _a97; _a97=this.configuration()["form"]["attributes"]["action"]; -this._hostname=_a97.replace(/https?:\/\/([^\/]*)\/.*/,"$1"); +this._hostname=_a97.replace(/^https?:\/\/([^\/]*)\/.*/,"$1"); } return this._hostname; },"favicon":function(){ @@ -36709,7 +36709,7 @@

loading ...

var _bf2; var _bf3; _bf2=this.formData()["attributes"]["action"]; -_bf3=_bf2.replace(/https?:\/\/([^\/]*)\/.*/,"$1"); +_bf3=_bf2.replace(/^https?:\/\/([^\/]*)\/.*/,"$1"); this._favicon="http://"+_bf3+"/favicon.ico"; } return this._favicon; @@ -36888,7 +36888,7 @@

loading ...

var _c1e; var url; url=this.bindings()["url"].field().value(); -if(/https?\:\/\//.test(url)==false){ +if(/^https?\:\/\//.test(url)==false){ url="http://"+url; } if(Clipperz_IEisBroken===true){ @@ -36898,7 +36898,7 @@

loading ...

var _c21; _c20=this.bindings()["username"].field().value(); _c21=this.bindings()["password"].field().value(); -/(https?\:\/\/)?(.*)/.test(url); +/(^https?\:\/\/)?(.*)/.test(url); _c1e=RegExp.$1+_c20+":"+_c21+"@"+RegExp.$2; } MochiKit.DOM.currentWindow().location.href=_c1e; @@ -36928,7 +36928,7 @@

loading ...

},this)); },"runDirectLogin":function(_c27){ var _c28; -if(/(https?|webdav|ftp)\:/.test(this.formData()["attributes"]["action"])==false){ +if(/^(https?|webdav|ftp)\:/.test(this.formData()["attributes"]["action"])==false){ var _c29; if(typeof (_c27)!="undefined"){ _c27.close(); @@ -38507,7 +38507,7 @@
Please enable scripting or upgrade your browser.
Terms of service - Privacy policy  -  - Application version: community.edition (revision 5) + Application version: community.edition (revision 6)
diff --git a/index_debug.html b/index_debug.html index 7d6313f..8a6e8ed 100644 --- a/index_debug.html +++ b/index_debug.html @@ -591,7 +591,7 @@
Please enable scripting or upgrade your browser.
Terms of service - Privacy policy  -  - Application version: community.edition (revision 5) + Application version: community.edition (revision 6)
diff --git a/js/src/Bookmarklet.js b/js/src/Bookmarklet.js new file mode 100644 index 0000000..daa633e --- /dev/null +++ b/js/src/Bookmarklet.js @@ -0,0 +1,372 @@ +_cble = null; + +//----------------------------------------------------------------------------- + +isLoginForm = function(aForm) { + var inputFields; + var passwordFieldsFound; + var i,c; + +//console.log("is login form: " + aForm.name + " (" + aForm.id + ")"); + passwordFieldsFound = 0; + inputFields = aForm.elements; + c = inputFields.length; + for (i=0; i