NOTE: The current preferred location for bug reports is the GitHub issue tracker.
Bug 812 - javascript return statement in event handlers not accepted
javascript return statement in event handlers not accepted
Status: RESOLVED FIXED
Product: Validator.nu
Classification: Unclassified
Component: Datatype library
HEAD
All All
: P2 normal
Assigned To: Michael[tm] Smith
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-01-19 12:32 CET by ar112
Modified: 2011-01-20 10:44 CET (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ar112 2011-01-19 12:32:49 CET
The validator does not accept the javascript return statement in event handlers.

For example the input:
<!DOCTYPE html><html><head><title></title></head><body onload="return"><p></p></body></html>
returns the error "invalid return".

This is caused by the org.whattf.datatype.FunctionBody checkValid function that calls a non-function-body javascript-parser.

Simplistic hack to work around this problem is to change in syntax/relaxng/datatype/java/classes/org/whattf/datatype/FunctionBody.java line 48:
Reader reader = new BufferedReader((new StringReader(
   literal.toString())));
to:
Reader reader = new BufferedReader((new StringReader(
   "function(event){" + literal.toString() + "}")));
Comment 1 Michael[tm] Smith 2011-01-20 10:44:12 CET
Thanks very much. Reading through the Rhino API docs, I couldn't find any canonical way it provides for doing this, but your proposed change seems to be a reasonable way, so I went ahead and made the change as you proposed.

https://bitbucket.org/validator/syntax/changeset/dc4d70a03fab

I have it deployed for testing at http://www.w3.org/html/check

If you give it a try their and notice any problems, feel free to reopen this bug or of course to raise others if they're not related to this on.