Download & Extend

Improper display of ampersand (&) in select list

Project:Content Taxonomy
Version:6.x-1.0-rc2
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review

Issue Summary

Improper display of ampersand (&) in select list. When adding a taxonomy as a CCK field and displaying it as a "Select List", it displays as &. See screenshot attached

It displays as expected in when choosing "Checkboxes/Radios".

AttachmentSize
Select List with ampersands22 KB

Comments

#1

Status:active» fixed

Hi!

Thanks for your report.
There was one check_plain too much for select lists, I fixed that and committed it to the D6 dev version.

#2

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

#3

Version:6.x-1.0-beta3» 6.x-1.0-rc1
Status:closed (fixed)» active

I have this issue in 6.x-1.0-rc1. The ampersand in select lists is rendered as &amp.

#4

Priority:normal» critical

This is important any ideas please?

#5

this may also depend on your CCK version. what version of cck are you using and is there a difference between content taxonomy beta6 and rc1?

#6

I just tried upgrading to the latest CCK module (6.x-2.4) and the problem remains. I have Content Taxonomy 6.x-1.0-rc1. Please advise, thanks.

#7

Now tried the 6.x dev but no difference.

#8

Priority:critical» normal

Out of desperation I tried editing it myself and by some miracle actually fixed it. I've attached a patch although I wrote it by hand and not sure if it follows the proper convention for patches. Either way it should be clear which line was changed.

AttachmentSize
content_taxonomy-correct_imroper_display_of_ampersands.patch 504 bytes

#9

removing check_plain is a bad idea and dangerous. additionally your patch wouldn't change anything for select list. maybe you have been adding another check_plain instead?

#10

If the check_plain is left in then the ampersands are displayed incorrectly. I'm not sure why nobody else is having this problem.

If anyone has an alternative solution then I'd be happy to try it, but this hack allowed an otherwise ready site to go live (even if removal of the check_plain impairs security).

#11

Status:active» postponed (maintainer needs more info)

I'm still wondering, why this patch changes something with select lists. The original code says:

$options[$term->tid] = ($field['widget']['type'] == 'content_taxonomy_select') ? $value : check_plain($value);

it does a check_plain for every widget (like radios/checkboxes), except for a select list.
if you remove the second check_plain it only can have effects on widget not of the type 'content_taxonomy_select'.
so, I have to ask again, which widget are you exactly using? you can see that in your field settings or in your database (table content_node_field_instance)

#12

Version:6.x-1.0-rc1» 6.x-1.0-rc2
Status:postponed (maintainer needs more info)» active

I noticed that my select lists returned to displaying & instead of &. I just installed the latest RC2 version (without any custom patches) and the problem remains. Any ideas?

Additional info.: the problem is within an exposed views form, which is used as a block within a panels page.

#13

I'm also having the same problem. I am using the select list for an exposed views filter and see the html entity instead of the ampersand character. I'm using the latest RC2 and have upgraded CCK to 2.6.

#14

subscribing

#15

The views exposed filter selector is separate from Content Taxonomy's CCK option widgets, so the problem you're experiencing might not be related to the initial issue.

I'm unable to duplicate the ampersand being rendered as & entity in the exposed filter select box. I'm using Drupal 6.16, Views 2.8, Content Taxonomy rc2, and CCK 2.6. Can you provide some steps to reproduce?

#16

same issue here.

drupal 6.16
views 2.10
content taxonomy 1.0 rc2
content taxonomy autocomplete 1.0 rc2
content taxonomy options 1.0 rc2
content taxonomy tree 1.0 rc2
option widgets 2.6

#17

Same issue here. I see it in select dropdowns and in checkboxes displayed in exposed filters. I've attached a screenshot of a list of checkboxes.

Drupal 6.16
Content Taxonomy 6.x-1.x-dev

AttachmentSize
Content Taxonomy Ampersand Bug.png 28.82 KB

#18

Here is what I did to solve this:

Open the form.inc (/drupal/includes/form.inc) and change line number 1447
from:
$options .= '<option value="'. check_plain($key) .'"'. $selected .'>'. check_plain($choice) .'</option>';
to:
$options .= '<option value="'. $key .'"'. $selected .'>'. $choice .'</option>';

Hope this helps!

#19

hi

editing the core modules is not advisable. what i did was edit a file from this module, instead of core module.

im using drupal 6.17 and content taxonomy 6.x-1.0-rc2.

the file is 'content_taxonomy/includes/views/content_taxonomy_handler_filter_many_to_one.inc'.

the original function,

...
  function get_value_options() {
    $options = content_taxonomy_allowed_values($this->content_field);
    unset($options['']);

    $this->value_options = $options;
  }
...

add a few lines in the middle.

...
  function get_value_options() {
    $options = content_taxonomy_allowed_values($this->content_field);
    unset($options['']);

    foreach ($options AS $i => $v) {
      $options[$i] = html_entity_decode($v);
    }

    $this->value_options = $options;
  }
...

im not sure how well this works for other encoding, but this solved this same problem i having with views list dropdowns.

#20

Status:active» closed (fixed)

Post 19 thanks that fixed it.

#21

Status:closed (fixed)» needs review

This needs to be reviewed and committed to the Content Taxonomy module correct? Thanks

#22

Status:needs review» needs work

Need a working patch with the change in #19 to test.

#23

Status:needs work» needs review

Patch of #19

AttachmentSize
content_taxonomy_301124.patch 909 bytes

#24

Thank you for the patch!

#25

sorry, i dont know ho to create a patch. thanks =)

#26

#27

Patch #23 works fine for me. Thanks.

#28

tested and confirmed, this should definitely be committed!!

#29

Patch in #23 fixes ampersands, but leaves single quotes encoded. The attached patch is a simple revision to #23 that also decodes single quotes.

AttachmentSize
content_taxonomy_301124-29.patch 611 bytes