Open Bug 901841 Opened 11 years ago Updated 2 years ago

Error message for invalid regular expressions in 'pattern' attribute lacks information about where it occurred

Categories

(Core :: DOM: Core & HTML, enhancement, P3)

enhancement

Tracking

()

People

(Reporter: sebo, Unassigned)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

Attached file Test case with invalid quantifier (deleted) —
When an <input> has an invalid regular expression set inside its 'pattern' attribute, the following error message will be logged to the console: SyntaxError: invalid quantifier This message lacks any source information, so you won't know where this error comes from and why it happened. It should refer to the element the pattern is defined for. For reference, this was first reported to Firebug.[1] Test case: 1. Open the attached patternError.html 2. Open the browser console via Ctrl+Shift+J => The console will list a "SyntaxError: invalid quantifier" message. Also this message seems to be logged twice while there is just one error. Reloading the page even logs it three times. Sebastian [1] http://code.google.com/p/fbug/issues/detail?id=6646
> It should refer to the element the pattern is defined for. How would you like it to do that?
IMO the best way would be to create a new interface inheriting from nsIConsoleMessage[1] similar to nsIScriptError[2], which has an attribute holding the reference to the element (similar to the 'target' property of events) instead of 'sourceLine' and 'columnNumber'. Sebastian [1] http://mxr.mozilla.org/mozilla-central/source/xpcom/base/nsIConsoleMessage.idl [2] http://mxr.mozilla.org/mozilla-central/source/js/xpconnect/idl/nsIScriptError.idl
https://bugzilla.mozilla.org/show_bug.cgi?id=906179 use this as a second test case. I don't know whether it's a js thing or a pattern attrib thing.
No message: http://hg.mozilla.org/mozilla-central/rev/3c0d0a2a7a60 Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0b5pre) Gecko/20100821 Minefield/4.0b5pre ID:20100821133553 invalid quantifier: http://hg.mozilla.org/mozilla-central/rev/455320ccc851 Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0b5pre) Gecko/20100821 Minefield/4.0b5pre ID:20100821175917 Pushlog: http://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=3c0d0a2a7a60&tochange=455320ccc851
Blocks: PortYarr
No longer blocks: PortYarr
Status: UNCONFIRMED → NEW
Ever confirmed: true
Depends on: 906179
Attachment #786154 - Attachment mime type: text/plain → text/html
Depends on: 1112040
The message improved a lot since a last checked. It now says "Unable to check <input pattern='^.**$'> because the pattern is not a valid regexp: nothing to repeat". Only the reference to the actual element where the error occurred is still missing. Sebastian
Blocks: jserror
Priority: -- → P3
Component: DOM → DOM: Core & HTML
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: