Closed Bug 1066001 Opened 10 years ago Closed 7 years ago

Network tab doesn't escape HTML in JSON responses

Categories

(DevTools :: Netmonitor, defect, P3)

x86_64
Linux
defect

Tracking

(Not tracked)

RESOLVED WORKSFORME

People

(Reporter: josh.tumath+bugzilla, Assigned: vincent, Mentored)

Details

(Keywords: good-first-bug, Whiteboard: [netmonitor-reserve])

Attachments

(1 file)

1. Open a page that receives a JSON response with HTML in it
2. Click on that response
3. Click on the preview tab

All of the HTML is interpreted, which can lead to some interesting results.
Thanks for the report!

Honza
Mentor: odvarko
Flags: qe-verify+
Keywords: good-first-bug
Priority: -- → P3
Whiteboard: [netmonitor-reserve]
Hi,

Can I work on this? :-)

Vincent
Sure!

Assigned to you. I am not sure if this is still a problem (there is no test case I could try) so, it would be nice if we can get one first.

Honza
Assignee: nobody → vi.le
I can reproduce the issue :

If a webserver is configured to send a Content-Type text/html for a json file, the content of the json file is interpreted as html in the preview tab. But this is the correct behavior, right ? Reporter, is that what you mean?

If a webserver sends a json response with the Content-Type application/json, then there is no preview tab and nothing is interpreted.
This a script to reproduce the issue:

run it with:

php -S 127.0.0.1:8080 -file test.php

then put this json in same directory as the script:

{"test":"<em>test</em"}

And point firefox to localhost:8080/test.json

test is in italic.
Thanks, the test case works for me.

Just a small typo, content of the JSON file should be (see the closing tag):

{"test":"<em>test</em>"}

Now, how do you want to fix this?

Honza
I'm not sure if this is really a bug. If the content type is text/html, it seems logical to me that firefox interpret the file as html. Is this the expected behavior?
Firefox appropriately looks at the MIMEtype of the document. In your example, the PHP server returns a `text/html` header when it is not html. Because of that, FF shows a preview pane. When the proper header `text/txt` or `text/json` is returned, firefox will not show a preview. I think this is a WORKSFORME.
Status: UNCONFIRMED → RESOLVED
Closed: 7 years ago
Resolution: --- → WORKSFORME
I wasn't sure. Thanks for taking a look!
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: