Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
base system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
24 Aug 2012 at 15:25 UTC
Updated:
29 Jul 2014 at 21:01 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
Anonymous (not verified) commentedThis patch resolves the issue.
It can be tested by running "curl -H "Accept: application/json" http://localhost/drupal/node/1" in the command line.
Comment #2
Anonymous (not verified) commentedAnother way (probably better) to solve this is to use the JsonResponse object's setData() instead of setContent().
Comment #3
larowlanComment #4
Anonymous (not verified) commentedInstead of calling setData, we can actually pass the array in as the first parameter when constructing the Response object.
Comment #5
Crell commentedIf we have an array, yes. Are you saying #2 doesn't work? The bot says it does, and it seems a simple enough fix.
Comment #6
Hanspolo commentedHere is another patch.
It calls the constructor with the data.
Using the data instead of content works fine with arrays.
Non-array data works as with the setContent() method.
Comment #7
patrickd commentedTested:
#1 works
#2 works <-- I personally prefere this one
#6 works
Comment #8
dries commentedCommitted #2 to 8.x. Thanks!
Comment #9
smartinm commentedIMHO this patch could introduce a security flaw: anyone can view the internal structure of a node. For example:
$ curl -H "Accept: application/json" http://localhost/sandbox/drupal-8.x/node/7Returns a string that contains a JSON representation of the node object:
Comment #10
smartinm commentedComment #11
Crell commentedI'm not clear how this issue introduces a sec. hole. This just fixes a bug. Right now, er, I'm not actually sure how we're returning JSON forms of nodes yet. :-)
Comment #12
smartinm commentedYou're right, the bugfix for this issue is correct but the patch has highlighted the security hole. I think the behavior of the new routing system when matching by HTTP Accept header can be an information disclosure threat.
Comment #13
Crell commentedWe're not matching by accept header yet.
This sounds like a new issue is needed. If you can, please make a test case that shows the hole and file it as a new issue, tagging it WSCCI and security. Thanks.
Comment #14.0
(not verified) commentedUpdated the issue summary with new information.