diff --git a/services/sync/modules/engines/forms.js b/services/sync/modules/engines/forms.js index e5de6384879..8e9ee8b5085 100644 --- a/services/sync/modules/engines/forms.js +++ b/services/sync/modules/engines/forms.js @@ -227,22 +227,68 @@ FormTracker.prototype = { notify: function FormTracker_notify(formElement, aWindow, actionURI) { if (this.ignoreAll) return; - + this._log.trace("Form submission notification for " + actionURI.spec); - + + // XXX Bug 487541 Copy the logic from nsFormHistory::Notify to avoid + // divergent logic, which can lead to security issues, until there's a + // better way to get satchel's results like with a notification. + + // Determine if a dom node has the autocomplete attribute set to "off" + let completeOff = function(domNode) { + let autocomplete = domNode.getAttribute("autocomplete"); + return autocomplete && autocomplete.search(/^off$/i) == 0; + } + + if (completeOff(formElement)) { + this._log.trace("Form autocomplete set to off"); + return; + } + /* Get number of elements in form, add points and changedIDs */ let len = formElement.length; let elements = formElement.elements; for (let i = 0; i < len; i++) { - let element = elements.item(i); - let inputElement = element.QueryInterface(Ci.nsIDOMHTMLInputElement); - - if (inputElement && inputElement.type == "text") { - this._log.trace("Logging form element: " + inputElement.name + "::" + - inputElement.value); - this.addChangedID(Utils.sha1(inputElement.name + inputElement.value)); - this._score += 10; + let el = elements.item(i); + + // Grab the name for debugging, but check if empty when satchel would + let name = el.name; + if (name === "") + name = el.id; + + if (!(el instanceof Ci.nsIDOMHTMLInputElement)) { + this._log.trace(name + " is not a DOMHTMLInputElement: " + el); + continue; } + + if (el.type.search(/^text$/i) != 0) { + this._log.trace(name + "'s type is not 'text': " + el.type); + continue; + } + + if (completeOff(el)) { + this._log.trace(name + "'s autocomplete set to off"); + continue; + } + + if (el.value === "") { + this._log.trace(name + "'s value is empty"); + continue; + } + + if (el.value == el.defaultValue) { + this._log.trace(name + "'s value is the default"); + continue; + } + + if (name === "") { + this._log.trace("Text input element has no name or id"); + continue; + } + + this._log.trace("Logging form element: " + name + " :: " + el.value); + this.addChangedID(Utils.sha1(name + el.value)); + this._score += 10; } } }; diff --git a/services/sync/services-sync.js b/services/sync/services-sync.js index 48c82c64d9c..9fc36f49c4f 100644 --- a/services/sync/services-sync.js +++ b/services/sync/services-sync.js @@ -32,6 +32,7 @@ pref("extensions.weave.log.logger.service.main", "Trace"); pref("extensions.weave.log.logger.async", "Debug"); pref("extensions.weave.log.logger.network.resources", "Debug"); pref("extensions.weave.log.logger.engine.bookmarks", "Debug"); +pref("extensions.weave.log.logger.engine.forms", "Debug"); pref("extensions.weave.log.logger.engine.history", "Debug"); pref("extensions.weave.log.logger.engine.tabs", "Debug"); pref("extensions.weave.log.logger.engine.clients", "Debug");