Manually editing source strips href tags

Created on 22 December 2023, 11 months ago
Updated 3 January 2024, 11 months ago

Problem/Motivation

Upgraded ck4 to 5.
Client has previously been (by appearances) manually editing using Source in D9 / ck4.
After update and deployment, nodes are edited by client, but when the Source button is hit, href is removed from the html.
As a result, the html renders the links but without the href, so they don't work.

Steps to reproduce

Created new node.
Selected Source.
Added: <a href="hello.com">Hello</a>
Saved
View node and/or edit node, the html source renders as

<p>
    <a>Hello</a>
</p>

This is on Drupal 10.2, which is the staging site.
However, the error was reported from the live site, which is running 10.1.7.

๐Ÿ› Bug report
Status

Closed: works as designed

Version

10.1 โœจ

Component
CKEditor 5ย  โ†’

Last updated about 22 hours ago

Created by

๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom niklp Nottingham

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

Comments & Activities

  • Issue created by @niklp
  • Status changed to Postponed: needs info 11 months ago
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    Steps to reproduce

    View node and/or edit node, the html source renders as

    <p>
        <a>Hello</a>
    </p>
    

    This is correct behavior. That's not the bug you reported in Drupal Slack!

    CKEditor 4 and 5 have both always required <br> and <p> to work correctly. CKEditor 4 tried its best to get by, but didn't actually support it; there were lots of things broken.

    IOW

    • โœ… The wrapping <p> isn't a bug.
    • โŒThe omission of the href is a bug.

    Problem

    After update and deployment, nodes are edited by client, but when the Source button is hit, href is removed from the html.

    Where are the steps to reproduce for this?

    This is not reproducible on a fresh Drupal 10.2 install:

    vendor/bin/drush site-install standard --yes --quiet --db-url=sqlite://sites/default/files/.ht.sqlite --account-name=root --account-pass=root
    

    followed by going to node/add/page, clicking the "Source" button and pasting

    <a href="hello.com">Hello</a>
    
    <p>
        <a href="hello.com">Hello</a>
    </p>
    
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    Your Text Format contains:

        - insert_block
        - video_embed_wysiwyg
    

    Can you please disable both those filters for a moment?

    I need steps to reproduce with only core. From a fresh install ๐Ÿ™

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    Oh โ€” one more thing!

    We can easily verify whether the incorrect HTML is generated by CKEditor 5, or by the filter system, without even doing #3! ๐Ÿ˜„

    Just go and look at the node__body table for the node you just edited: does that still contain the href?

  • Status changed to Closed: works as designed 11 months ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom niklp Nottingham

    Issue was narrowed down to IMCE.module - Closing; thanks Wim.

  • @NikLP can you link to the IMCE issue?

    i updated from 10.1.7 to 10.2.0 and, without editing any pages, a lot of my pages' html is broken, with

  • tags, tags and oithers being stripped out. havent checked the database tables yet
Production build 0.71.5 2024