Carriage returns result in ascii encoded 

Created on 16 December 2019, almost 5 years ago
Updated 26 June 2023, over 1 year ago

Hi there,

I might be misunderstanding how to use the module, so I have submitted this as a support request.

We have a description field which contains "\r\n", smart_trim does its thing, but at the point it returns Html::serialize($dom) the php function saveToXML() encodes the \r as 
.

This happened after the upgrade from 8.x-1.1 to 8.x-1.2.

I'll attach an (ugly) patch which resolves the issue for us in the meantime.

Thanks!
Ant

πŸ’¬ Support request
Status

Postponed: needs info

Version

2.1

Component

Code

Created by

πŸ‡³πŸ‡ΏNew Zealand code_brown

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡«πŸ‡·France xavier.masson Haute-Normandie

    I've reroll the patch for the 2.1.x and just applied the same code as applied in the Drupal core for that issue Html::transformRootRelativeUrlsToAbsolute() replaces "\r\n" with " \n" (#3311595) β†’

  • First commit to issue fork.
  • Status changed to Postponed: needs info over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States ultimike Florida, USA

    Before any patch is reviewed, we need to have a failing test for this issue. The following is what is needed:

    1. A sample string.
    2. The number of characters or words to smart trim the sample string by.
    3. The correct result after smart trimming the sample string.

    Here's my attempt (but in all honesty, I'm not sure if my "correct result" is what we're looking for):

    1. "Carriage return test \r\n from issue 3101169"
    2. 35 characters
    3. 'Carriage return test \n from'

    Currently, with the proposed fix in place (I actually put it in TruncateHTML->init()) this test does not pass. Smart Trim instead returns this:

    'Carriage return test 
    from issue'

    So, setting this to "Postponed (maintainer needs more info)" so that we can get some solid test data.

    Also - I've created an issue fork for this (with my failing test and proposed fix), future work on this issue should be there (not in patches).

    Thanks everyone, for your efforts so far!
    -mike

  • πŸ‡©πŸ‡ͺGermany maacl

    The Issue I referenced 3 years ago has been closed as duplicate of #3311595: Html::transformRootRelativeUrlsToAbsolute() replaces "\r\n" with " \n" β†’ , which has been fixed in 10.1. Does this fix the Issue here?

  • πŸ‡ΊπŸ‡ΈUnited States ultimike Florida, USA

    @maacl - I am honestly not sure, mainly because I am unsure of the desired outcome. If the desired outcome is to not have an encoded character returned, then my test yesterday indicates that the issue is not fixed.

    Like I wrote in my previous comment, we really need a definitive test case for this task before we can proceed.

    -mike

Production build 0.71.5 2024