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.
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:
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.
Comments
Comment #1
jamessw commentedThe 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.
Comment #2
jamessw commentedHere's a patch that actually handles this issue, adding the single and double quotes.
Comment #3
jamessw commentedComment #4
boshtian commentedConfirming that the patch in #2 works and is counting correctly for me.
Comment #5
MaskOta commentedPatch in #2 worked for me but i added 2 more exceptions(± and §).
Also all get replaced by ' ' now instead of just one.
Comment #6
boshtian commentedHad 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.
Comment #7
boshtian commentedComment #8
icicleking commentedComment #9
scotwith1tPatch worked for me. +1 for adding to next release. Thanks!
Comment #10
peter.thorndycraft commentedThis 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:
Would the attached work appropriately?
Comment #11
rajiv.singh commentedAdded some improvement in patch of #10
1) trim()
2) renamed from .diff to .patch
Comment #12
hitchshockIt works for me. We need apply both patches: #6 and #11
RTBC
Comment #13
dalinShouldn'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.
Comment #14
cedeweyWe 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.