When we need to go in and add a title_suffix (i.e. if we are on Page 2 or more), we call drupal_get_title() to get the page title, but Drupal gives this back to us encoded, that is, after a check_plain.

We need to decode this because something else is happening to it again. Alternatively, we need to use a different function that drupal_get_title() in order to find the page title.

This is a (very simple) patch to decode the entities (including quotes). (This was generated from a git diff so I wasn't sure if this would actually be a valid patch file, but since the fix is so simple, I thought displaying it might be enough.)

--- a/sites/all/modules/smart_paging/smart_paging.module
+++ b/sites/all/modules/smart_paging/smart_paging.module
@@ -582,7 +582,7 @@ function smart_paging_field_attach_view_alter(&$build, $context) {
             }
             $markup_content = $field_content['#markup'];
             if ($current_page > 0) {
-              $title_suffix  = drupal_get_title() . t('@page', array('@page' => $suffix . ($current_page + 1
+              $title_suffix  = htmlspecialchars_decode(drupal_get_title(), ENT_QUOTES). t('@page', array('@p
               drupal_set_title($title_suffix);
             }
           }

Comments

rwohleb’s picture

Subscribe.

arpeggio’s picture

Status: Needs review » Postponed (maintainer needs more info)

Hi, what version are you using? The line code that needs replacement in your patch doesn't exist anymore. Thanks.

farshid’s picture

Hi

Facing same problem in 7.x-1.3 in smart_paging.module on line: 1176

Problem: a title with single quote like: "this is it's :)"
go to page 2 and you should see: "this is it's :) : Page 2 of 2"

my solution: add PASS_THROUGH to drupal_set_title on line 1176 so that would be:

- drupal_set_title(drupal_get_title() . $title_suffix);
+ drupal_set_title(drupal_get_title() . $title_suffix, PASS_THROUGH);

Works, but we may need to check_plain the $title_suffix too (I do not know if some user with admin permissions could add some sort of XSS,... to the suffix or not):

- drupal_set_title(drupal_get_title() . $title_suffix);
+ drupal_set_title(drupal_get_title() . check_plain ($title_suffix), PASS_THROUGH);

one thing I was wondering: why a second call to check_plain converts single quote to ' ??

test:

/**
 * Root directory of Drupal installation.
 */
define('DRUPAL_ROOT', getcwd());

require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

$title = "this is it's :)";
echo $title;
echo '<br />';
echo check_plain($title);
echo '<br />';
echo check_plain(check_plain($title));

prints:

this is it's :)
this is it's :)
this is it&#039;s :)
arpeggio’s picture

Status: Postponed (maintainer needs more info) » Fixed

Hi, I have tested/committed/pushed your patch. Please use the dev version. Thank you for the patch.

Status: Fixed » Closed (fixed)

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

ronny89’s picture

Version: 7.x-1.2 » 7.x-1.3

set proper version