There's a couple issues in the queue related to single quotes being double-escaped, including #559056: Fields with apostrophes not displaying correctly and #1373584: Apostrophes (single quotes) in token values used for link path in "Output this field as a link" are double-escaped. Drupal has a decode_entities() function to "undo" a check_plain(), so here's a patch that changes all occurrences of html_entity_decode() to decode_entities().

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Version: 7.x-3.x-dev » 6.x-3.x-dev
FileSize
4.55 KB

Wow i never saw this function before, drupal is full of hidden awesomeness. Thanks for fixing this issue on such many places,
as all of them were potential bugs. Committed the patch to 7.x-3.x, sadly the patch didn't applied to 6.x-3.x, so i created one.

byrond’s picture

Looks like the first patch has already been committed to 7.x-3.x-dev.

http://drupalcode.org/project/views.git/commit/dcf5b6acfcbe5546bde0e2c81...

mennonot’s picture

Any idea when this patch will be applied to 6.x-3.x-dev? Or has it already been?

effulgentsia’s picture

Status: Needs review » Reviewed & tested by the community

@dereine, your patch looks like a straight port of the D7 patch, so I'm marking it RTBC. If you intended to leave it as "needs review", because you were actually looking for a D6-targeted review, please kick it back.

dawehner’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 6.x-3.x as well. Thanks for the review

Status: Fixed » Closed (fixed)

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

mennonot’s picture

Status: Closed (fixed) » Active
FileSize
147.01 KB

I installed the most recent version of Views 6.x-3.x-dev (updated 2012-Mar-09) and the apostrophe issue is not fixed. It looks like the patch in this thread has not been applied yet. I checked the first instructions in the patch by opening up /handlers/views_handler_field.inc and found that at line 941 its still using html_entity_decode instead of decode_entities:

  // html_entity_decode removes <front>, so check whether its different to front.
    if ($path != '<front>') {
      // Use strip tags as there should never be HTML in the path.
      // However, we need to preserve special characters like " that
      // were removed by check_plain().
     $path = strip_tags(html_entity_decode(strtr($path, $tokens)));

If 1373588-decode_entites-6.patch (attached to comment #1 above) had been applied, it should have read like this:

 // strip_tags removes <front>, so check whether its different to front.
     if ($path != '<front>') {
       // Use strip tags as there should never be HTML in the path.
       // However, we need to preserve special characters like " that
       // were removed by check_plain().
      $path = strip_tags(decode_entities(strtr($path, $tokens)));

I've also attached a screenshot of a caption mangling an apostrophe with 6.x-3.x-dev installed.

mcdruid’s picture

This change would also fix an issue we've come across over in Advanced Forum:

#1361526: htmlspecialchars() error with views created by AF

I can confirm that changing to decode_entities (or adding 'UTF-8' as the optional 3rd param to html_entity_decode) resolves the "htmlspecialchars(): Invalid multibyte sequence in argument" warning which is emitted by check_plain in certain circumstances.

I don't know if the same error has come up in any other context, or whether you'd like a new issue opened in the views queue for this?

mcdruid’s picture

...and that IIUC it looks like the patch has yet to land in the latest dev releases as of today (at least in terms of replacing the occurrence which is causing AF problems):

views-6.x-2.x-dev/handlers/views_handler_field.inc:632:      $options['attributes']['title'] = html_entity_decode($alt, ENT_QUOTES);
views-6.x-3.x-dev/handlers/views_handler_field.inc:996:      $options['attributes']['title'] = html_entity_decode($alt, ENT_QUOTES);
_vid’s picture

It's not in the views 6.x-3.x-dev 2012-Mar-23 release either.

RedRat’s picture

Raised priority accordantly with http://drupal.org/node/45111 and changed status to "tested by community" since this patch already in the 7.x branch. We really need this bug to be fixed!

mennonot’s picture

Priority: Normal » Major
Status: Active » Reviewed & tested by the community

+1 for getting this patch added. It looks like this bug may break the views integration with SlideShowPro (http://drupal.org/project/ssp). When views sends a caption with a double escaped apostrophe or quote to SlideShowPro, the player won't load at all

peaton’s picture

I'm using 7.x-3.3+155-dev and still have this issue with the apostrophe. Is the patch not included in that dev version?

dawehner’s picture

Status: Reviewed & tested by the community » Needs review

I disagree with being major, as major is not meant to be for your website but for the module, anway.

It is a bit confusing because noone actually verified that the attached patch is working fine for them.

Chris Matthews’s picture

Issue summary: View changes
Status: Needs review » Closed (outdated)

The Drupal 6 branch is no longer supported, please check with the D6LTS project if you need further support. For more information as to why this issue was closed, please see issue #3030347: Plan to clean process issue queue