- Issue created by @betarobot
- 🇬🇧United Kingdom james.williams
I had the opposite issue - I had footnotes containing URLs that weren't explicitly links, but the text format for my body text has the 'Convert URLs into links' filter enabled. So
https://www.google.com
within my content used to come out as an actual link in the footnotes. Since upgrading to 4.0.x, my footnote was just that URL as plain text, not a link.I attach the patch I used to solve my problem by invoking an alter hook whilst upgrading the content (so I could pass my content through that filter/format in a custom module's implementation of this hook). Maybe this patch can help you too as it allows bespoke tweaks to the upgraded content? And/or it might be worth thinking through what your text formats' configuration will be doing to escape the footnotes' content.
For reference, this is my custom module's implementation of the hook - it's quite specific to my needs, but might be a helpful example:
/** * Implements hook_footnotes_upgrade_3x4x_alter(). */ function MYMODULE_footnotes_upgrade_3x4x_build_alter(&$build, $context) { // Upgraded footnote content needs putting through the URL filter. $format = \Drupal::entityTypeManager() ->getStorage('filter_format') ->load('filtered_html'); if ($format instanceof \Drupal\filter\FilterFormatInterface) { /** @var \Drupal\filter\Plugin\Filter\FilterUrl $filter */ if ($filter = $format->filters('filter_url')) { $build['#attributes']['data-text'] = $filter->process( $build['#attributes']['data-text'], // Language code is actually ignored by this particular filter. \Drupal::languageManager()->getDefaultLanguage()->getId() )->getProcessedText(); } } }
- Status changed to Needs work
7 months ago 8:27am 13 September 2024 - 🇬🇧United Kingdom scott_euser
Thanks James, would be good to get to the bottom of the issue itself, but I would be happy to merge your alter hook if it helps or helps others:
- Could you please make it a MR so tests run (in this case just making sure we don't introduce code quality)
- Could you please add the standard api.php file to document the alter hook
Thanks!
- Merge request !56Issue #3470527: Allow altering upgraded footnotes content → (Merged) created by james.williams
- Status changed to Needs review
7 months ago 10:30am 13 September 2024 - 🇬🇧United Kingdom james.williams
@scott_euser OK, done! I didn't really expect this to be something accepted into the module, as I figured it bypasses what the module expects. But hopefully it's useful for at least 2 of us!
- 🇬🇧United Kingdom scott_euser
Anything that makes it easier to upgrade is helpful :) Thank you!
Nobody is maintaining the 3x version yet lots of sites still use it, at that will eventually becoming more and more problematic. The upgrade is so hard to make one size fits all, so really helpful to have these type of options for anyways what is temporary code until everyone is moved off the old version.
Just a small phpcs error it seems in the pipeline
- 🇬🇧United Kingdom scott_euser
Cheers thanks! The php next major I'm addressing in 🐛 Interface for CKE4 to 5 upgrade stops existing in Drupal 11 Active so ignore that
-
scott_euser →
committed db2328fd on 4.0.x authored by
james.williams →
Issue #3470527 by james.williams: 3 to 4 upgrade escaping html
-
scott_euser →
committed db2328fd on 4.0.x authored by
james.williams →
- 🇬🇧United Kingdom scott_euser
Wonder whether to mark this as fixed, or continue to attempt to find the root problem in your case. Perhaps others can comment if they come across similar issue and also need to use the alter hook.
For now will mark as fixed so you get the issue credit for the work here - thank you!
- Status changed to Fixed
7 months ago 11:57am 13 September 2024 - 🇬🇧United Kingdom james.williams
Thanks! And yeah, I did wonder what that missing interface report was about :) I did have a little look into why content might have been (double?-) escaped, but couldn't see an answer.
Automatically closed - issue fixed for 2 weeks with no activity.