Closed (fixed)
Project:
Views (for Drupal 7)
Version:
6.x-2.x-dev
Component:
exposed filters
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
6 Jul 2009 at 21:25 UTC
Updated:
9 Nov 2009 at 10:00 UTC
Jump to comment: Most recent file
Comments
Comment #1
dave reidThey appear just fine using Firefox. That's the standard HTML entity for the ampersand and should display as '&'. Which browser are you using?
Comment #2
avpadernoI am using Safari 4 under Mac OS X 10.5.7. I also tried with Firefox 3.0.11, and I have the same problem.
Comment #3
avpadernoI checked at the source of the page, and I noticed that the string I reported is coded as "
reviewed & tested by the community"; in this case, a browser can just render&as&.For that I remember, that is the normal behavior browsers should keep.
Comment #4
dave reidI don't see that HTML at all. All I see is in the source is
reviewed & tested by the community. Also tested with Safari 4 with Vista.Comment #5
dave reidAha! Now I see what you mean: the status select field, not the actual status values in the issue listings. I can confirm it looks double encoded. PS screenshots are helpful.
Comment #6
avpadernoAlso "won't fix" is not rendered correctly, in the browsers I am using. See the images I attached to the comment.
Comment #7
avpadernoTo complete the test, I also tried with Firefox on a Windows XP PC, and I see the page in the same way I reported.
Comment #8
avpadernoYes, I meant that.
If you see that, then it's confirmed that the issue is not specific for a particular platform.
Comment #9
avpadernoThis is actually true also for the issue queue of a project (see the attachment).
Comment #10
avpadernoComment #11
avpadernoAre there news about this problem?
Comment #12
dwwThis is either a bug in project_issue's views integration (likely) or in views itself (unlikely). Either way, it's not specific to d.o. Probably we're just double-escaping the status options in some cases. Should be relatively easy to find and fix if anyone's interested in looking under project_issue/views/handlers/*filter*.
Comment #13
avpadernoIn this page, the status field is shown correctly. Maybe it only happens with exposed filters.
The question is then: what is done with exposed filters that is not done with not exposed ones?
EDIT: The screenshots I used show the advanced search page because I was not able to take a screenshot of the drop down menu; the problem is anyway present also with the exposed filters present in a project issue queue.
Comment #14
dwwI tracked this down to a bug in views, introduced here:
http://drupal.org/cvs?commit=223804
http://drupal.org/cvs?commit=223802
This code is a bit overzealous. ;) We've got an exposed filter using views_handler_filter_in_operator. Here's the problem:
A) views_handler_filter_in_operator::value_form() has the following:
at this point, value_form_type is still 'checkboxes', so we escape everything. We need this since FAPI is inconsistent and does not automatically escape the '#options' values for checkboxes, even though it does so for every other form element.
B) views_handler_filter::exposed_form() calls
this->value_form()and gets the form array, still as type checkboxes, with all of the elements still check_plain()'ed.C) views_handler_filter::exposed_form() then calls
$this->exposed_translate($form[$value], 'value');. views_handler_filter::exposed_translate() contains the following:Once our form element's '#options' array has been check_plain()'ed to make it secure as checkboxes in step (A), it now gets double-escaped by FAPI when the form element is converted into a 'select' box. :(
So, it seems like we're doing the check_plain() on the '#options' array way too early in the game. We need to do that later down the chain of events, because once we check_plain() assuming we're going to be 'checkboxes' there's no good way to invert that and get back to the unescaped values for use in 'select'...
I'll try to ping Earl about this in IRC and see if we can work out a viable solution that neither opens us up to XSS again, nor leads to double-escaping.
/me curses at FAPI's inconsistent checkboxes behavior again!!!
Comment #15
damien tournoud commentedI would simply add a #pre_render to the checkboxes widget, instead of destructively modifying the options:
Comment #16
dww@Damien: Lovely idea! However, #pre_render won't work here because it's #type checkboxes and we're setting #process to use 'expand_checkboxes', and then #pre_render won't help. :( So, I'm using a #process callback to process the #options array (before we call expand_checkboxes), and now it all works great.
I added a project issue status code with the name
<script>alert('issue-status-xss')</script>. There's still no XSS when you edit/configure an exposed filter, because the #process is still invoked to do the array_map(). However, there's no double-escaped values in the exposed filters on the advanced search page since when we decide to turn the element back into a 'select' box, we unset the #process to check_plain() the options. See attached patch...@merlinofchaos: any objections, or should I commit this? ;)
Comment #17
dwwFixed typo in the PHPDoc for views_process_check_plain_options() and removed a stray newline.
Comment #18
dwwNot sure if this is more legible (or faster), but here's a copy using array_search() instead of iterating over #process ourselves.
Comment #19
dwwGot Earl to look at this in IRC. He pointed out that if the #process callback was a bit smarter, we wouldn't even have to worry about unsetting it when we switch something back to 'select'. The callback can just test
$element['#type']and only do the check_plain if it's checkbox*. See attached patch. Tested to confirm this is still working properly and doesn't introduce XSS.Comment #20
cgjohnson commentedIs this patch the only way to fix this issue with exposed filters in views? I'm not a developer and am intimidated by the idea of installing a patch....
thanks,
cj
Comment #21
andirez commentedHello cj, I just checked and the current DEV version seems to have the patch applied. So just download that version (called 6.x-2.x-dev) instead of the current official 2.6 release.
Comment #22
dwwIndeed, this was committed to both HEAD and DRUPAL-6--3:
http://drupal.org/cvs?commit=267356
http://drupal.org/cvs?commit=267354
So yeah, the fix will be out in the next official release...