Hi,
I am getting the lots of jquery error, So It would break all the jquery functionality in that page.
Steps to reproduce the issue :
1. Set Body field format as Trimmed with limit (100 char) in Teaser mode
2. Create article node with tag in body field
for example :
<p><em>Globally myocardinate orthogonal communities through frictionless leadership skills. Completely engage client-based customer service and cross-platform human capital. Professionally generate vertical web-readiness rather than magnetic data. Distinctively target optimal infomediaries via synergistic products. Interactively develop vertical manufactured products and highly efficient niche markets.</em></p>
Add these in the body field. and save the node.
3. Then see the article node in teaser mode, you would see the jquery errors.
Before patch - italics apply to the rest of the page:
After patch - italics are correctly clipped at the end of the summary:
Comment | File | Size | Author |
---|---|---|---|
#52 | 2714131-52.patch | 5.56 KB | Akram Khan |
#51 | 2022-11-17_00-05.png | 88.4 KB | stpaultim |
#47 | 2714131-47.patch | 5.58 KB | VladimirAus |
#34 | 2714131-34.patch | 635 bytes | jibran |
Comments
Comment #2
dawehnerI would argue that this is sort of major, as for example there is a workaround of just uninstalling the quickedit module
Comment #3
Anonymous (not verified) CreditAttribution: Anonymous commentedLooking at this bug, if you enable "Correct faulty and chopped off HTML" on admin/config/content/formats/manage/basic_html (or whatever text format you're using) this problem is fixed.
However, I think the HTML should be corrected on trimmed text no matter what, the errors shouldn't ever happen in the first place. Here's a patch to text.module when trimming that fixes the problem.
Comment #4
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #5
Anonymous (not verified) CreditAttribution: Anonymous commentedAlso, to clarify the bug is when trimming the text to 100 characters. the p and em tags are not ended properly and you have faulty HTML in the body field.
Comment #6
cilefen CreditAttribution: cilefen commentedCan you not use them "Correct faulty" and trim at the same time successfully?
Comment #7
Anonymous (not verified) CreditAttribution: Anonymous commentedThe point of the solution is that the "trim" display formatter cannot be used reliably without also using the "correct faulty HTML" setting, and you should be able to IMO.
Comment #8
cilefen CreditAttribution: cilefen commentedIt seems for sure there would be no other way. Drupal can trim text, but if that leaves tags hanging open, it is the site builder's responsibility to check the box "correct faulty HTML".
Comment #9
Anonymous (not verified) CreditAttribution: Anonymous commented??? so conflicts with the quickedit module are acceptable if the site builder is magically expected to know that "correct faulty HTML" option exists when configuring their field display? I think closing this is a bit bold and this is a site builder UX fail.
Comment #10
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #11
cilefen CreditAttribution: cilefen commentedWhat would you have Drupal do to fix this?
Comment #12
Anonymous (not verified) CreditAttribution: Anonymous commentedThe proposed patch fixes the issue... so that. If you have a trim display formatter it should correct the HTML of the display regardless.
Comment #13
cilefen CreditAttribution: cilefen commentedSorry for the grumpiness, not having a great day here—that's not your fault.
So this is effectively checking the box for them?
Comment #14
Anonymous (not verified) CreditAttribution: Anonymous commented:) no problem. It does effectively do the "correct faulty HTML" in the event of a trim display formatter. An assumption on Drupal's part, maybe, but probably a good one in most cases since otherwise it requires someone to actually know the "correct faulty HTML" option exists. Maybe others can weigh in whether or not it should do that.
I can see a use case where one display mode uses "trim" while another uses default that doesn't want the correct faulty HTML option checked in the text format. In that case, "trim" should still work and not cause JS conflicts due to incomplete HTML tags.
Comment #15
cilefen CreditAttribution: cilefen commented8.0.x is closed for development.
Comment #23
pameeela CreditAttribution: pameeela commentedI've confirmed this is still occurring, but I don't think it meets the criteria for Major since there is a very easy workaround of enabling "Correct faulty and chopped off HTML".
Incredibly, the patch still applies, and it works as advertised. Updated IS with screenshots of before and after. Leaving in review as this seems simple enough but the patch still needs a code review.
Comment #24
jibranLet's add some tests.
The code comment can't be > 80 chars.
Comment #25
pameeela CreditAttribution: pameeela commentedUpdated patch attached with a shorter comment.
Comment #26
Ramya Balasubramanian CreditAttribution: Ramya Balasubramanian at Srijan | A Material+ Company for Drupal India Association commentedComment #27
jibranTurns out we already have tests for this and they are failing. With the fix this time.
Comment #28
pameeela CreditAttribution: pameeela commentedNot ready for review since it needs tests and now we're debating whether it's even a bug - since the patch breaks existing tests.
Comment #29
pameeela CreditAttribution: pameeela commentedOK jibran's patch may fix the tests so this is ready for review, if it passes.
Comment #32
jibranThere was random fail in first run which is gone after another test run. Now patch is ready for a review.
Comment #33
quietone CreditAttribution: quietone as a volunteer commentedSo, the test TextSummaryTest.php was passing but was testing the wrong strings and it now updated to test for the correct HTML.
Why is the faulty HTML only fixed when there is s format?
There are also coding standard errors.
Comment #34
jibranThe more I think about it the more it feels like a 'work as designed' to me. Here is why:
If the answer to this question is, yes, we should fix that too then that would mean
\text_summary()
will fix all the faulty chopped trims so why even havefilter_htmlcorrector
in the first place. This is the only use offilter_htmlcorrector
here.I think this is a support request and OP needs to enable
filter_htmlcorrector
filter to fix the problem.Anyway, here the fix only patch without tests for anyone who needs that. Please don't test it.
Comment #35
pameeela CreditAttribution: pameeela commentedWhy is the faulty HTML only fixed when there is s format?
The 'Trimmed' formatter is only available for formatted text fields, so this only applies when there is a format. Unless I am misunderstanding the question?
Comment #36
jibranThe 'Trimmed' formatter is only available for formatted text fields, so this only applies when there is a format.
This statement is incorrect. Trimmed is not a format. Trimmed is just for summary fields, in the context of this issue. A summary field has the same filter as its corresponding textarea. A summary field get trimmed either by<!--break-->
string,text.settings.default_summary_length
, or the size provided to\text_summary()
. The trimmed output is only corrected whenfilter_htmlcorrector
is part of the format.Here are three cases:
filter_htmlcorrector
is not set.filter_htmlcorrector
is set.Comment #37
pameeela CreditAttribution: pameeela commentedErr - yes it is? And this issue occurs when using it, regardless of whether there is a summary involved. And it is not applicable to plain text fields.
This is a screenshot of the display settings for a Text (formatted, long, with summary) field:
This is a screenshot of the display settings for a Text (formatted, long) field:
This is a screenshot of the display settings for a Text (plain, long) field:
Comment #38
jibranLOL, @quietone and I are talking about filter format or text format in the UI and you are talking about field formatter and formatted fields which are textfield, textarea, and textarea with summary with filter format.
These are filter formats:
It is true that from the UI you can't set format to NULL but
\text_summary()
can work with NULL format hence @quietone's question.Comment #39
pameeela CreditAttribution: pameeela commentedI know that you were talking about text formats, that is why I said it's not possible to use the trimmed formatter on a field that doesn't have a text format :)
Comment #40
VladimirAusThanks for the commit.
Works on
8.9.2
,9.0.3
and9.1.x
.Seems like it was working for most of the tags but
strong
Comment #41
larowlanWe don't seem to have any new test coverage here?
ie. if this resolves a bug, why isn't an existing test failing?
Comment #44
quietone CreditAttribution: quietone as a volunteer commentedStill needs a test.
Comment #45
mohit_aghera CreditAttribution: mohit_aghera at QED42 commentedWhile attempting to write the test cases for the issue, I noticed a few things:
- To resolve current failures, I had to fix multiple test cases so it passes existing tests. Mainly those are related to expected strings only.
Is it the right approach? I am not sure if there can be additional regressions.
I need some inputs from someone.
- I added a test case to validate the string normalization. Is it sufficient or we need to render and check string over there as well?
Keeping "Needs tests" tag as it is until we have conclusion on above points.
Comment #47
VladimirAusThe logic has changed in 9.3. Updated patch.
Comment #51
stpaultim CreditAttribution: stpaultim commentedThis might be a slightly different issue, but I want to post this because it might help folks with a problem that looks a LOT like this problem if you are trimming content in a views rewrite field.
Check the "Field can contain HTML" option to fix it.
Comment #52
Akram Khanreroll Patch for 10.1.x