Problem/Motivation

The module is only decoding first occurence of   at the moment, while other popular HTML entities are ignored. This especially affects CKEditor, because it returns encoded entities that are counted as more than 1 character.

Steps to reproduce

  • Enable max length for CKEditor-enabled field.
  • Enter < into the CKEditor area in WYSIWYG mode.
  • The counter is expected to decrease by 1, but it changes by 4.

Proposed resolution

Decode at least the most common entities: & < > " and all occurrences of the non-breaking space, not just the first one.

Remaining tasks

No.

User interface changes

No.

API changes

No.

Data model changes

No.

Issue fork maxlength-3233046

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Dmitriy.trt created an issue. See original summary.

dmitriy.trt’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new3.06 KB

Submitted MR!2.

I'm also attaching a diff at commit f8f2ee28 for a stable reference from composer files.

dmitriy.trt’s picture

Issue summary: View changes

Added information about issue with decoding the &nbsp; that is also fixed by the MR.

cedewey’s picture

Version: 8.x-1.x-dev » 2.0.x-dev
cedewey’s picture

Assigned: Unassigned » hipp2bsquare

Assigning to Jeff to review.

cedewey’s picture

Jeff to review and look into whether there's JavaScript function that can be used to address this.

hipp2bsquare made their first commit to this issue’s fork.

hipp2bsquare’s picture

Assigned: hipp2bsquare » cedewey

I created a new merge request -- MR 15, 3233046-simplified-decode-html-entities

This is based on Dmitriy.trt's work, but it doesn't try to define a set, limited list of html entities -- it instead finds and string using the html entity structure ( &chars;) and treats them as a single character for the purposes of counting and truncation.

Clayton, I'm turning this over to you to test. Thanks!

cedewey’s picture

Assigned: cedewey » srdtwc
Status: Needs review » Reviewed & tested by the community

I've tested this out with <, &nbsp; and " and they all now count as expected. Marking reviewed and tested and assigning to Steven for a final code review.

hipp2bsquare’s picture

  • hipp2bsquare committed 968d7d4 on 2.0.x
    Issue #3233046 by hipp2bsquare, Dmitriy.trt, cedewey, srdtwc: Decode...
hipp2bsquare’s picture

Status: Reviewed & tested by the community » Fixed

srdtwc and I did peer code review. This work is merged into the dev branch. Thanks everyone for your contributions.

Status: Fixed » Closed (fixed)

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