Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
views_handler_filter::prepare_filter_select_options()
tries to convert HTML to plain-text for displaying select options. It does this in a completely bogus way:
strip_tags(decode_entities($label));
This will convert a<b
into a
, because the <
entity is decoded before stripping the tags.
The correct way would be:
decode_entities(strip_tags($label));
But I suggest this instead, which more closely keep the intend of the markup:
trim(str_replace("\n", " ", drupal_html_to_text($value)));
Comment | File | Size | Author |
---|---|---|---|
#8 | views-html2plaintext-1793236-08.patch | 535 bytes | David Castella |
Comments
Comment #1
dawehnerLink to the original issue: #1413750: escaped html element in html select element of exposed filter the actual patch had the right way to to it, but i just suggested to do it the wrong way :(
Comment #2
Shevchuk CreditAttribution: Shevchuk commentedAny news on this issue?
Comment #3
dawehnerSorry, please don't post such pointless comments. It annoys everyone. If there is an update, there is a comment.
Comment #4
capellicI added this to a JS file in a module I created for various admin overrides. No, not the ultimate solution.
Comment #5
mpdonadioThis issue was linked from another one I was following (https://drupal.org/comment/7082854#comment-7082854). Here is a quick patch with Damien's suggestion. It works for me, but I was having trouble coming up with a good case to check against.
Comment #6
brahimmouhamou CreditAttribution: brahimmouhamou commentedAlso views_plugin_exposed_form:exposed_form_alter executes a check_plain() to convert special characters to HTML entities which leads to problems when use quotes or ampersands.
Comment #8
David Castella CreditAttribution: David Castella commentedHey, there is a bug into the patch #5, with this patch, you will see id and not the label.
here is a corrected version
Comment #9
Chris Matthews CreditAttribution: Chris Matthews as a volunteer commentedThe 3 year old patch in #8 to views_handler_filter.inc applied cleanly to the latest views 7.x-3.x-dev and if still relevant needs to be reviewed.
Comment #10
Chris Matthews CreditAttribution: Chris Matthews as a volunteer commentedUnassigning @dawehner