diff --git a/webcompat/form.py b/webcompat/form.py index 4ec7a8424..496afff4f 100644 --- a/webcompat/form.py +++ b/webcompat/form.py @@ -37,7 +37,7 @@ (u'unknown_bug', u'Something else - I\'ll add details below') ] -url_message = u'A URL is required.' +url_message = u'A valid URL is required.' image_message = (u'Please select an image of the following type:' ' jpg, png, gif, or bmp.') radio_message = u'Problem type required.' diff --git a/webcompat/static/js/lib/bugform.js b/webcompat/static/js/lib/bugform.js index 6af478a00..ef455688e 100644 --- a/webcompat/static/js/lib/bugform.js +++ b/webcompat/static/js/lib/bugform.js @@ -18,7 +18,7 @@ function BugForm() { 'url': { 'el': $('#url'), 'valid': null, - 'helpText': 'A URL is required.' + 'helpText': 'A valid URL is required.' }, 'problem_type': { 'el': $('[name=problem_category]'), @@ -189,10 +189,19 @@ function BugForm() { } }; - /* Check to see that the URL input element is not empty. - We don't do any other kind of validation yet. */ + this.isReportableURL = function(url) { + return url && !(_.startsWith(url, 'about:') || + _.startsWith(url, 'chrome:') || + _.startsWith(url, 'file:') || + _.startsWith(url, 'resource:') || + _.startsWith(url, 'view-source:')); + }; + + /* Check to see that the URL input element is not empty, + or if it's a non-webby scheme. */ this.checkURLValidity = function() { - if ($.trim(this.urlField.val()) === '') { + var val = this.urlField.val(); + if ($.trim(val) === '' || !this.isReportableURL(val)) { this.makeInvalid('url'); } else { this.makeValid('url'); @@ -264,7 +273,7 @@ function BugForm() { inlineHelp.insertAfter('label[for=' + id + ']'); break; case 'problem_type': - inlineHelp.appendTo('.wc-Form-information'); + inlineHelp.appendTo('fieldset .wc-Form-information'); break; case 'image': // hide the error in case we already saw one