Comments

jamessw’s picture

The logic for handling special characters is currently only in tinymceChange(), so it only applies to tinymce wysiwyg. This patch moves it to strip_tags, as the logic should be wysiwyg agnostic.

I think it's okay to have strip_tags also handle stripping special characters- I don't see a reason to separate stripping html tags and dealing with special characters as they both share the intention of showing the display length, not the storage length.

jamessw’s picture

StatusFileSize
new1.96 KB

Here's a patch that actually handles this issue, adding the single and double quotes.

jamessw’s picture

Status: Active » Needs review
boshtian’s picture

Confirming that the patch in #2 works and is counting correctly for me.

MaskOta’s picture

Patch in #2 worked for me but i added 2 more exceptions(± and §).

Also all   get replaced by ' ' now instead of just one.

boshtian’s picture

Had an issue with another character: » and «.

Actually it's counting wrong for all characters from A0 - FF because they are represented with HTML names instead of an actual character.

I created a patch that covers all the characters which are represented in format &charname; and replaces them with empty space, so they count for one.

boshtian’s picture

Version: 7.x-3.0-beta1 » 7.x-3.2
icicleking’s picture

Status: Needs review » Reviewed & tested by the community
scotwith1t’s picture

Patch worked for me. +1 for adding to next release. Thanks!

peter.thorndycraft’s picture

This patch works great for the front end, however the node cannot be submitted as the text is still too long. Looking at the field validation, the frontend code is not taken into consideration:

    $value = filter_xss(str_replace(array("\r\n", ' '), array(' ', ' '), $element['#value']), array());
    if (drupal_strlen($value) > $element['#attributes']['maxlength']) {

Would the attached work appropriately?

rajiv.singh’s picture

Added some improvement in patch of #10
1) trim()
2) renamed from .diff to .patch

hitchshock’s picture

It works for me. We need apply both patches: #6 and #11
RTBC

dalin’s picture

Status: Reviewed & tested by the community » Needs work

Shouldn't this be using htmlspecialchars_decode() to account for any kind of encoded character? Similarly on the JS side this should be using https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global... rather than hard-coding a list of characters.

cedewey’s picture

Status: Needs work » Closed (won't fix)

We are only maintaining the Drupal 7 version of the module for critical security fixes, so I'm marking this Closed (works as designed). Thank you reporting this issue. If you do want to maintain the Drupal 7 version, do reach out. We'd be happy to bring you on board as a maintainer.

I also encourage you, if you haven't already, to upgrade your site to Drupal 8/9. We are actively maintaining that version and you enjoy all of the other features of the latest version of Drupal.