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

Code breaks if < is used within the redactor field #24

Closed
terryupton opened this issue May 26, 2020 · 10 comments
Closed

Code breaks if < is used within the redactor field #24

terryupton opened this issue May 26, 2020 · 10 comments
Labels

Comments

@terryupton
Copy link

terryupton commented May 26, 2020

Currently, have a situation where the less than character (<) is used within the redactor field.
What is occurring is that content is getting cut off just before this character appears until the next html character. In this instance a new

tag.

When outputting this natively with twig code the character renders and there are no issues.

Here is this code for the retcon use case:

  {{ content | retcon([
    ['attr', 'h2', { class: 'font-semibold text-gray-900 text-2xl pt-12 mb-4' }],
    ['attr', 'h3', { class: 'font-semibold text-gray-900 text-lg pt-6 mb-4' }],
    ['attr', 'ul', { class: 'ml-8 list-disc' }],
    ['attr', 'ol', { class: 'ml-8 list-lower-roman' }],
    ['attr', 'li', { class: 'mb-4' }],
    ['attr', 'a', { class: 'text-blue-500 hover:text-green-500 underline hover:underline' }],
    ['attr', 'blockquote', { class: 'italic text-18 text-lime-600 font-light mx-8 my-12 pl-4 py-2 border-l-6 border-lime-600' }],
    ['attr', 'mark', { class: 'text-pink-500 bg-pink-100 p-px italic' }],
    ['removeEmpty'],
  ]) }}

I have tested with just content|raw with native twig output and it renders just fine.

I have not explored a solution, but thought I would raise this issue as it has occurred.

Thanks.

@terryupton
Copy link
Author

Oh here is some copy to test with.

WAO application upstream of anaerobic digestion is intended to enhance the biodegradability of the organic matter in the downstream AD reactor. For this duty, lower temperatures (100–200 °C) and pressures (<20 bar) are used, sometimes with the addition of a catalyst. The WAO performance is measured in terms of the increase in either the liquid−phase organic carbon, or the subsequent removal of volatile suspended solids (VSS) by the AD process.

Most recently, there has been interest in the potentially high-value intermediate oxidation products (low molecular weight organic compounds such as acetic and propionic acid) generated by WAO. While these carboxylic acids are produced in appreciable concentrations by the WAO process, extracting and purifying them for reuse remains a challenge.

Note the (< 20- bar ) [art in the first paragraph.

@mmikkel
Copy link
Owner

mmikkel commented May 27, 2020

Ouch. Thanks for reporting @terryupton – I'll have a look at this as soon as I have the time.

I spent exactly 30 seconds thinking about this :D but if you need a temporary hotfix, you could maybe try to replace the < character with something else, then add the Retcon filter, then convert back to the proper char? I.e. something like this:

{{ entry.body | replace({ '<': '%lessthan%' }) | retcon(...) | replace({ '%lessthan%': '<' }) }}

@terryupton
Copy link
Author

Thanks @mmikkel - I am still in the development phase so it's not causing me a huge issue. However, hoping it isn't a hugely complicated fix for you. Look forward to the update/patch. :-)

@mmikkel mmikkel added the bug label May 31, 2020
@mmikkel
Copy link
Owner

mmikkel commented May 31, 2020

@terryupton I think I've got a fix for this issue – if you're able to help me test it, that'd be much appreciated.

composer require mmikkel/retcon:dev-dev#a25040575c3b18e3b1b55448e7359795c2b87e14

I'll cut a new release once I'm confident I didn't break anything else (at that point you can do a simple composer require mmikkel/retcon to install the latest stable release).

Thanks!

@terryupton
Copy link
Author

Hi @mmikkel - thanks for the prompt fix. I will certainly help to test. I will aim to get onto this today/tomorrow and pass some feedback.

@mmikkel
Copy link
Owner

mmikkel commented Jun 1, 2020

@terryupton I appreciate that, thanks!

@terryupton
Copy link
Author

Hi @mmikkel - apologies a day later than I had hoped to get onto this.
I have updated to your dev branch and I have done some testing.
Everything seems to be working nicely now.
I have tested each special character individually throughout the content and there are no breakages. here are the characters I tested.

!@£$%^&*(){}[]_-+=~`;:'""|?><,.

I am happy and confident this fix has resolved the issue, so on my part, feel free to commit and push this out.

Thanks again.

@mmikkel
Copy link
Owner

mmikkel commented Jun 4, 2020

Thanks for the feedback @terryupton! Much appreciated.

I'm going to try and get some additional testing done over the weekend and hopefully have a new release out early next week.

@terryupton
Copy link
Author

Sounds good.

@mmikkel
Copy link
Owner

mmikkel commented Jul 19, 2020

Resolved in Retcon 2.2.0

@mmikkel mmikkel closed this as completed Jul 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants