Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

article css styles with child selectors get broken during handling #4081

Open
chzauleck opened this issue Jan 16, 2025 · 2 comments
Open

article css styles with child selectors get broken during handling #4081

chzauleck opened this issue Jan 16, 2025 · 2 comments
Assignees
Labels
bug Something isn't working as intended style Beautify please
Milestone

Comments

@chzauleck
Copy link
Contributor

When replacing special characters with HTML Codes in (richtext) articles the css child selector > also gets replaced.

Original:

.ck-content .image>figcaption {
    /* stuff */
}

In the OTOBO Article:

.ck-content .image>

figcaption {
    /* stuff */
}
@chzauleck chzauleck added the bug Something isn't working as intended label Jan 16, 2025
@bschmalhofer bschmalhofer added this to the OTOBO 11.0 milestone Jan 21, 2025
@bschmalhofer
Copy link
Contributor

Hi @chzauleck,

I looked into this issue but I think that I do not understand the part about article css styles. I take AgentTicketPhone as an example. Creating an article with the content

.ck-content .image>figcaption {
    /* stuff */
}

gives an article that contains

.ck-content .image>figcaption {
    /* stuff */
}

The > is replaced by the HTML entity &gt. This substitution is done in the method Kernel::System::HTMLUtils::Safety(). This makes sense as we are in text content. There is no tag to be closed by an >.

The part that I don't understand is why one would want to add CSS in the message. Internal CSS would be in a style attribute where CSS selectors are not supported anyways. Let's discuss that first before I dig deeper into the Safety method.

@bschmalhofer bschmalhofer self-assigned this Jan 21, 2025
bschmalhofer added a commit that referenced this issue Jan 22, 2025
concerning special, and some not so special, characters
bschmalhofer added a commit that referenced this issue Jan 22, 2025
concerning special, and some not so special, characters
@bschmalhofer
Copy link
Contributor

Discussed this with @chzauleck . The problem with the > does not really concern the body of the HTML. This issue is primarily about <style> tags in the HTML header. Replacing an > with &gt; does break the declared CSS.

The cause of the effect seems to be in the Safety() method. More precisely in the underlying HTML::Scrubber module. See https://metacpan.org/dist/HTML-Scrubber/source/lib/HTML/Scrubber.pm#L300 . See also the discussion in nigelm/html-scrubber#1 , nigelm/html-scrubber#18 and in https://rt.cpan.org/Public/Bug/Display.html?id=2991 .

Incidently OTOBO already uses a patched version of HTML::Scrubber. So special casing that case should be feasible.

bschmalhofer added a commit that referenced this issue Jan 22, 2025
This is actually unwanted behavior as the encoding breaks the CSS.
bschmalhofer added a commit that referenced this issue Jan 23, 2025
This is actually unwanted behavior as the encoding breaks the CSS.
bschmalhofer added a commit that referenced this issue Jan 23, 2025
because '>' is needed as the child combinator in CSS
bschmalhofer added a commit that referenced this issue Jan 23, 2025
This is actually unwanted behavior as the encoding breaks the CSS.
bschmalhofer added a commit that referenced this issue Jan 23, 2025
because '>' is needed as the child combinator in CSS
@bschmalhofer bschmalhofer added the style Beautify please label Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working as intended style Beautify please
Projects
None yet
Development

No branches or pull requests

2 participants