Bug 57035 - Web Inspector: render XHRs matching JSON regex as JSON.
Summary: Web Inspector: render XHRs matching JSON regex as JSON.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (Deprecated) (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-24 10:28 PDT by Pavel Feldman
Modified: 2011-03-24 11:11 PDT (History)
10 users (show)

See Also:


Attachments
[IMAGE] Screenshot with patch applied. (150.55 KB, image/png)
2011-03-24 10:30 PDT, Pavel Feldman
no flags Details
Patch (12.57 KB, patch)
2011-03-24 10:38 PDT, Pavel Feldman
yurys: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Pavel Feldman 2011-03-24 10:28:27 PDT
Patch to follow.
Comment 1 Pavel Feldman 2011-03-24 10:30:12 PDT
Created attachment 86794 [details]
[IMAGE] Screenshot with patch applied.
Comment 2 Pavel Feldman 2011-03-24 10:38:29 PDT
Created attachment 86798 [details]
Patch
Comment 3 Yury Semikhatsky 2011-03-24 10:59:34 PDT
Comment on attachment 86798 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=86798&action=review

> Source/WebCore/inspector/front-end/RemoteObject.js:219
> +                buffer += ", ";

Why not use Array.join instead?

> Source/WebCore/inspector/front-end/ResourceJSONView.js:41
> +    var start = /[{[]/.exec(text);

I vaguely recall that it's not uncommon to use a sequence of all kinds of brackets instead of while(1) to prevent XSS in this case. I don't remember details though and in particular whether the brackets should be opening or closing ones, you may want to double check.

> Source/WebCore/inspector/front-end/ResourceJSONView.js:42
> +    if (start && start.index)

Can it be a valid JSON string if it doesn't contain no { nor [ ?
Comment 4 Pavel Feldman 2011-03-24 11:01:57 PDT
> I vaguely recall that it's not uncommon to use a sequence of all kinds of brackets instead of while(1) to prevent XSS in this case. I don't remember details though and in particular whether the brackets should be opening or closing ones, you may want to double check.

I did check, they prepend closing brackets.

> > Source/WebCore/inspector/front-end/ResourceJSONView.js:42
> > +    if (start && start.index)
> 
> Can it be a valid JSON string if it doesn't contain no { nor [ ?

Sure, it can be a string or a number.
Comment 5 Pavel Feldman 2011-03-24 11:11:41 PDT
Committed r81878: <http://trac.webkit.org/changeset/81878>