Problem/Motivation

Follow-up of #88183: Relative URLs in feeds should be converted to absolute ones

To reproduce

1. Enable twig debug
2. Clear cache
3. Visit /rss.xml

You get an almost empty page and the following error in log/next page:

Warning: DOMDocument::loadXML(): XML declaration allowed only at the start of the document in Entity, line: 6 in Drupal\Core\EventSubscriber\RssResponseRelativeUrlFilter->transformRootRelativeUrlsToAbsolute() (line 47 of core/lib/Drupal/Core/EventSubscriber/RssResponseRelativeUrlFilter.php).

Proposed resolution

If parsing fails, log error and display original XML?

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Berdir created an issue. See original summary.

Berdir’s picture

Status: Active » Needs review
Issue tags: +Needs tests
FileSize
997 bytes
dawehner’s picture

Should we alternatively try to strip the twig tags right from the start?

Berdir’s picture

We can try that, but I think this could also be useful if there's some other error in the RSS.. unescaped raw content or so that would break it as well. And we shouln't silently drop all output because of that.

dawehner’s picture

Fair point. IMHO it would be great to open up an issue to try to output twig debug output maybe just in HTML context, whatever this means :)

twistor’s picture

We absolutely should break the RSS page if the XML is invalid.

There's no room for Postel's law in XML.

Berdir’s picture

I think you misunderstand the purpose of this change.

Right now we try to parse, fail and *completely hide any kind of output*, making it very hard to debug and figure out what is actually wrong with your XML.

This is not about trying to accept invalid XML, quite the opposite. If we encounter something invalid, then we abort and display it unaltered. So this is the very opposite of postel's law.

twistor’s picture

Sounds good to me

dawehner’s picture

Priority: Normal » Major

IMHO this happens quite often, for example when you have some weird embed codes in your html, see #2833987: \Drupal\Core\EventSubscriber\RssResponseRelativeUrlFilter in combination with \Drupal\filter\Plugin\Filter\FilterHtmlCorrector and script tags empty RSS feeds for a duplicated issue. Given that I believe this is major

dawehner’s picture

Here is a test for this particularity funny problem.

Berdir’s picture

Issue tags: -Needs tests

Can we get a test-only patch? I trust you, but you know, rules :)

I wrote the actual fix, so can't really RTBC.

dawehner’s picture

I had the file locally actually, just didn't uploaded it

Status: Needs review » Needs work

The last submitted patch, 12: 2801097-test.patch, failed testing.

Wim Leers’s picture

Status: Needs work » Reviewed & tested by the community

RTBC'ing #10.

  • alexpott committed 8f2befb on 8.3.x
    Issue #2801097 by dawehner, Berdir: Converting feed to absolute URLs...

  • alexpott committed 256756e on 8.2.x
    Issue #2801097 by dawehner, Berdir: Converting feed to absolute URLs...
alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 8f2befb and pushed to 8.3.x. Thanks!
Committed 256756e and pushed to 8.2.x. Thanks!

  • alexpott committed 8f2befb on 8.4.x
    Issue #2801097 by dawehner, Berdir: Converting feed to absolute URLs...

  • alexpott committed 8f2befb on 8.4.x
    Issue #2801097 by dawehner, Berdir: Converting feed to absolute URLs...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.