This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 6521 - add JSON callback support
Summary: add JSON callback support
Status: NEW
Alias: None
Product: Validator
Classification: Unclassified
Component: Templates (show other bugs)
Version: 0.8.4
Hardware: All All
: P2 enhancement
Target Milestone: ---
Assignee: This bug has no owner yet - up for the taking
QA Contact: qa-dev tracking
Depends on:
Reported: 2009-02-02 22:35 UTC by Olivier Thereaux
Modified: 2009-02-04 01:54 UTC (History)
1 user (show)

See Also:

main program with callback support but no verification of the json value (3.53 KB, patch)
2009-02-04 01:20 UTC, Karl Dubost
the template for the json output with the callback value (335 bytes, patch)
2009-02-04 01:21 UTC, Karl Dubost

Description Olivier Thereaux 2009-02-02 22:35:22 UTC
As requested on the mailing-list by brian gianforcaro:

This post
describes json support for the Markup validator.
It mentions that it followed the design of

One of the feature's that supports for it's JSON output
is  JSONP or JSON callback parameter.
Essentially the entire json is rapped in a function call that you
specify, very nice for some specific use cases.

I havn't found this feature to be supported on the markup validator.
Have I missed something?

If not I would like to submit a feature request to add " callback " as
a parameter to the validator when output is set to "json".
Comment 1 Karl Dubost 2009-02-03 16:26:59 UTC
I asked henri sivonen how it was supposed to work.

[01:32]  <hsivonen> karl: not by default, but you can get a callback by appending &callback=foo to the URL
[01:36]  <karl> hsivonen: oh I see :) so the foo is more the choice of the developer who wants to use the output
[01:36]  <hsivonen> karl: you can use any ECMAScript-compatible identifier in place of foo
[01:37]  <hsivonen> (yes, it actually validates whether it is an ECMA-compliant ident)
[01:37]  <karl> hsivonen: what I meant… is that the "foo" is not imposed by me but by the user
[01:38]  <hsivonen> karl: foo is chosen by whoever puts together the URL
[01:38]  <karl> cool
[01:38]  <karl> thanks

So the template is to be modified and the main source code to give the possibility of constructing such URI and sending to the template. It also seems that we have to be careful about the "foo" value which as to be a valid ECMAscript identifier. So a sanitizer seems to be necessary.
Comment 2 Olivier Thereaux 2009-02-03 16:32:51 UTC for the Identifier syntax.

If we're lazy and want to use a CPAN module to validate the syntax:
Comment 3 Karl Dubost 2009-02-04 01:20:22 UTC
Created attachment 621 [details]
main program with callback support but no verification of the json value
Comment 4 Karl Dubost 2009-02-04 01:21:22 UTC
Created attachment 622 [details]
the template for the json output with the callback value
Comment 5 Karl Dubost 2009-02-04 01:22:28 UTC
This is a first attempt at creating the callback feature. For now there is no checking if the value is an authorized ECMAScript identifier.
Comment 6 Olivier Thereaux 2009-02-04 01:54:04 UTC
(In reply to comment #3)
> Created an attachment (id=621) [details]
> main program with callback support but no verification of the json value

I looked at the diff, seems like you were working from a slightly outdated version of the check script. Hopefully a cvs update should merge properly. 

Other than that, great start. Let's see if we can perhaps figure out a regexp for what is an acceptable ECMASCIPT identifier? Then we'd be ready to go.