Problem/Motivation
Summary
When creating an RSS feed display and submitting it for validation to the w3c validator, the latter makes a recommendation that should be implemented - https://validator.w3.org/feed/docs/warning/MissingAtomSelfLink.html
Steps to reproduce
- Enable views & views_ui
- Go to
admin/structure/views/add, create a view with aFeeddisplay withFormat: RSS Feed, assign it a title and a path and make it accessible to anonymous users (see this screenshot) - Save the view
- Go to http://validator.w3.org/feed/
- Under 'Validate by URI' tab, enter the URL of the feed
Expected result
- The RSS feed validates without complaining
Actual result
- A message shows up saying it is a best practice to use an atom:link tag (see this screenshot)
- The RSS 2.0 spec seems to recommend the same
Proposed resolution
Patch suggested in #5 (this can be tested on https://simplytest.me/ for instance).
When validating the view with the patch, the W3C validator does not complain (see this screenshot).
Related Issues
- This problem occurs when using Drupal's core RSS feed #365498: Add missing atom:link with rel="self" to RSS feeds
- This problem does not occur when using views_rss
Original report by jvieille
I am trying to subscribe a LinkedIngroup to the rss feeds from a Drupal web site.
This feed is generated by my frontpage view.
No items are collected from linkedIn, and I am suspecting some strict validation control by LinkedIn
Feed validator says that the RSS feed is valid, but reports errors
http://validator.w3.org/feed/
the feed address is http://web2.see.asso.fr/rss.xml
- "description should not contain relative URL references"
- "Use of unknown namespace: http://drupal.org/group/og"
- "style attribute contains potentially dangerous content: white-space: pre;"
- "Invalid HTML: EOF in middle of construct"
- Missing atom:link with rel="self"
Thanks for help
| Comment | File | Size | Author |
|---|---|---|---|
| #51 | 1337894-51.patch | 3.29 KB | ammar_ar |
| #39 | reroll_diff_36-37.txt | 2.21 KB | ericgsmith |
| #39 | 1337894-37.patch | 3.17 KB | ericgsmith |
Issue fork drupal-1337894
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #1
simone.girlanda commentedI got the same problem, my rss feed is produced using a views.
I've validated it and I got just this warning:
- Missing atom:link with rel="self"
linkedin do not publish my feed.
How can I add this reference in my feed ?
This is my feed: http://www.datacheck.it/news/feed
to jvieille: I think that you have to change your feed content to eliminate all other issues.
Comment #2
kars-t commentedHi
I am closing this issue to clean up the issue queue. Feel free to reopen the issue if there is new information and the problem still resides. If not please make sure you close your issues that you don't need any more.
Maybe you can get support from the local user group. Please take a look at this list at groups.drupal.org.
Comment #4
alexmcl commentedI get the same problems with LinkedIn groups rejecting RSS feeds from my site. Specifically, http://validator.w3.org/feed gives:
description should not contain relative URL references
Missing atom:link with rel="self"
My feed is http://www.indigoblue.co.uk/rss/tag/nfp
I could not see any reference to this being fixed in Views 6.x-3
Comment #5
fengtanUpdating issue description and attaching a patch suggestion.
Comment #6
annya commentedIt is fixed by patch in #5 by Fengtan(Thank you!). I confirm that it works as it should.
Comment #7
Anonymous (not verified) commentedThis patch was applied before the release date of Views 7.x-3.11.
The issue still occurs with that version.
Could somebody confirm whether or not this patch was pushed through in that version?
Comment #8
fengtan@freddi the patch is not included in views-7.x-3.11 -- at the moment it is pending the review of a Views maintainer
Comment #9
deja711 commentedAny progress?
Comment #10
fengtanAttaching screenshots so it is easier for people to understand the issue and the solution.
Comment #11
fengtanComment #12
fengtanComment #13
dawehnerSeems reasonable, thank you!
Comment #14
fengtanI tried to port the patch to Drupal 8 - see file attached.
It is not quite working yet since the
<atom:link>tag gets auto-escaped in the Twig template, and also the way of rendering the tag (#markup) could be improved, but maybe this can help.Comment #17
joco_sp commentedIs there any news for D8?
Comment #18
catchComment #22
plato1123 commentedDo Drupal RSS feeds not validate? Using Drupal 8.3.7:
Not sure if same issue but I find RSS feeders don't see the feed on the page, don't auto detect it but some will see it if we paste the link in, others will not. Frustrating. We replaced an old wordpress site where RSS readers would find the feed easily.
Comment #23
omegadela commentedAs of Drupal 8.3.7 patching RSS.php with :
Allow the RSS to validate aigainst the atom:link warning.
(Patch attached for 8.5.x)
Comment #25
omegadela commentedFixing test failings by removing the namespace from the element after parsing.
Comment #29
ronaldmulero commented#25 fixes missing atom link for me.
Thank you omegadela!
Drupal core 8.9.2
Comment #30
jungleWould be great to have test coverage. 9.1.x is the current dev branch.
Comment #34
robpowellI applied this patch in 9.3.3. After refreshing and exporting my xml, the xml validator broke saying something was wrong. Unfortunately I couldn't debug further.
Comment #36
neclimdulHere's a simple test.
Mixed feelings on the implementation.
Pro:
Con:
Comment #37
neclimdulwoops, here's the patch
Comment #39
ericgsmith commentedReroll against 10.1.x (automerge / no conflicts)
Comment #40
jedihe commented#39 applies cleanly on top of 9.5.0.
Comment #41
bserem commentedIndeed it also applies to 9.5.2 whereas #37 does not apply to 9.5.2
Comment #42
lendudeAre we sure this is always going to return the correct path? Is the display always set to the RSS display when we reach this point or can we get a page display or a fatal error here?
Also, I agree with #36, is this the best way to fix this? This could lead to the same element being there multiple times. It might be the best way, but having some validation for this route over changing the template would be good.
Comment #43
kazah commentedStill errors of unknown namespaces...
Comment #45
lendudeThe IS is still talking about D7 and contrib View, where it looks like this has actually been addressed, so could somebody update the IS to make it more current? I'm assuming this is still an issue
Comment #46
nicxvan commentedAside from the issue summary update, there is a fix here for the cdata that is out in 11.0 and 10.4 #3433: Use CDATA in XML RSS Feeds.
The core rss feed should be generated on that version and run through a validator to identify any remaining issues.
Comment #47
ericgsmith commentedComment #48
ericgsmith commentedHave tested on 11.x and it still producing the same recommendation. Updated the issue summary steps to remove reference to drupal 7 and use terminology in the current views UI - also tweaked to title to clarify this is a recommendation not an error.
Comment #50
ericgsmith commentedMoved the existing patch to an MR.
Tested again and Len's comment is #42 is correct - this patch causes an error when following the steps to reproduce. Once you add the new view and before saving it the preview will through an exception as we are trying to get a route for a view that does not exist.
Once the view is saved the validation recommendation is resolved - leaving as "Needs work" as the approach to resolve the issue does not have consensus.
Comment #51
ammar_ar commentedreroll the patch against 10.4.1
Comment #53
neclimdulWorked around the creation failure with a quick check.
Would have expected _something_ to have been there but I guess not. Otherwise I would expect the view to be populated so we wouldn't get an empty URL in normal usage.
Comment #54
smustgrave commentedAppears to have phpstan issue, also could use a rebase
If you are another contributor eager to jump in, please allow the previous poster(s) at least 48 hours to respond to feedback first, so they have the opportunity to finish what they started!
Comment #56
ericgsmith commentedFix in #53 doesn't fix the error.
PHPStan is correct, view is always present here - this issue is when toString is called on the URL object and it goes through the route handler - it is here a route not found exception is thrown that
Route "view.foo.feed_1" does not exist.. This is applicable for both a new view and adding a new display to a view.First thought was that we can do
Url::fromUserInput('/' . $this->view->getPath())->setAbsolute()->toString();which does return the correct path when the view is not saved - but then I noticed in views UI its actually saying "Path: This display has no path." above the preview.Looking at https://git.drupalcode.org/project/drupal/-/blob/main/core/modules/views... it checks using hasUrl which catches that exception.
This means that the preview shows based on the saved route - but it keeps in consistent with the UI.
Comment #57
ericgsmith commentedComment #58
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #59
smustgrave commentedThink the bot was wrong on this one.
Comment #60
smustgrave commentedThis one feels super close, left 1 comment on the MR