Closed Bug 967393 Opened 10 years ago Closed 10 years ago

Make the jsonp regex a bit more relaxed

Categories

(DevTools :: Netmonitor, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Firefox 30

People

(Reporter: vporof, Assigned: vporof)

Details

(Whiteboard: [qa-])

Attachments

(2 files)

I've seen jsonp requests in the wild (like on http://www.nytimes.com/) that don't strictly adhere to the jsonp syntax, but they're still valid javascript, so they work. Our regex to identify those requests is very strict. We should gracefully handle all types of jsonp.
Attached patch v1Splinter Review
Assignee: nobody → vporof
Status: NEW → ASSIGNED
Attachment #8369923 - Flags: review?(rcampbell)
Attached image new regex
Visualization for the new regex.
Attachment #8369965 - Attachment description: regex → new regex
As a clarification, the first captured group is the jsonp callback, and the second group is the actual json object passed as a param to the callback.
Comment on attachment 8369923 [details] [diff] [review]
v1

Review of attachment 8369923 [details] [diff] [review]:
-----------------------------------------------------------------

r+. just add some description to that regex and this is good to go.

::: browser/devtools/netmonitor/netmonitor-view.js
@@ +2138,5 @@
>          jsonObjectParseError = e;
>        }
>        if (jsonMimeType || jsonObject) {
>          // Extract the actual json substring in case this might be a "JSONP".
> +        let jsonpRegex = /^\s*([\w$]+)\s*\(\s*([^]*)\s*\)\s*;?\s*$/;

can you describe what this regex is doing in a comment, please? Having to decode this is cruel.
Attachment #8369923 - Flags: review?(rcampbell) → review+
maybe you can data-uri-encode that png as documentation. ;)
https://hg.mozilla.org/mozilla-central/rev/b96fb0f79460
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → Firefox 30
Whiteboard: [qa-]
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: