Problem/Motivation
When I create an RSS Feed view and assign the RSS setting "Link" to my path field added to the View, I'm receiving the following (example):
The website encountered an unexpected error. Please try again later.</br></br><em class="placeholder">InvalidArgumentException</em>: The internal path component 'http://cmslocal.gfs.com/en-us/ideas/minding-the-menu-labeling-law' is external. You are not allowed to specify an external URL together with internal:/.
It seems like at some point the "Path" content field within Views now outputs an absolute URL. Or at least it does for me and I can't change it, even with the checkbox "Use absolute link (begins with "http://")" unchecked. Perhaps it's because my project is using the Domain module.
Regardless, I believe the RSS row plugin should allow both absolute and relative. I'm not sure there's a good reason it doesn't?
Steps to reproduce
- Create a views RSS feed display.
- Configure the display to show fields: Format > Show: Fields
- Add all required fields to the display.
- For the link field, use "Link to Content" and enable "Use absolute link" for this field.
- Configure the display's RSS fields:
- Map the link field to the link field create above in #4.
- Map the GUID field to the link field create above in #4, and enable "GUID is permalink".
- Save the view - however the preview most likely already failed
- View the page for the RSS feed
- Bug:
The website encountered an unexpected error. Please try again later.</br></br><em class="placeholder">InvalidArgumentException</em>: The internal path component 'http://cmslocal.gfs.com/en-us/ideas/minding-the-menu-labeling-law' is external. You are not allowed to specify an external URL together with internal:/.
Proposed resolution
Update the \Drupal\views\Plugin\views\row\RssFields to detect absolute links and output them correctly.
Remaining tasks
None
User interface changes
None
API changes
None
Data model changes
None
Release notes snippet
NA
| Comment | File | Size | Author |
|---|
Issue fork drupal-2918784
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:
- 2918784-views-rss-row
changes, plain diff MR !5437
- 2918784-10.1.x
changes, plain diff MR !5438
Comments
Comment #1
Anonymous (not verified) commentedvilepickle created an issue. See original summary.
Comment #2
Anonymous (not verified) commentedComment #3
Anonymous (not verified) commentedHere is a first patch
Comment #4
Anonymous (not verified) commentedComment #7
mstef commentedWorks for me (8.5.3)
Comment #9
shawnb commentedThe patch works for me as well (8.6.3)
Comment #10
sfdrummer commentedI've had a similar problem with the RSS formatter messing up links. A link like https://example.com/insights/news/news-article was being output as https://example.com/news/news-article. So this renders the RSS feed unusable, and checking "Use absolute link" causes the issue with the external link.
The way I've managed to fix this (which I don't like), is to check "Output the URL as text" for the "Link to content" field. Then under "Rewrite results" select "Override the output of this field with custom text", and enter "/ /{{ view_node }}".
This looks to me like a URL being exploded by "/" and the wrong segment being stripped perhaps. Hope this helps someone.
Comment #12
jennypanighetti commentedUpdated patch for 8.7.x.
Comment #13
jennypanighetti commentedComment #15
jennypanighetti commentedIgnore patch #12, it broke other items. Trying this patch instead.
Comment #16
rakesh.gectcr@jennypanighetti I am changing the status to needs review, Sot that the test will against your new patch.
Thanks,
Rakesh James
Comment #17
drup16 commentedreroll for core v8.7.7.
patch seems to be giving error at
error: patch failed: core/modules/views/src/Plugin/views/row/RssFields.php:6Comment #19
drcolossos commentedThe patches seem to be mixed up. This is a re-roll against the latest 8.7.x.
Comment #20
jennypanighetti commentedThat patch failed for me:
Comment #21
jennypanighetti commentedComment #22
agrochal commentedI attach interdiff file for last two patches(#19 and #21).
Comment #23
agrochal commentedThe same interdiff as in #22, just changed name to be proper.
Comment #24
Anonymous (not verified) commentedIt seems that this ended up getting fixed in Drupal 8.8.
See https://www.drupal.org/project/drupal/issues/2673980
Comment #25
Anonymous (not verified) commentedComment #26
jrearickI don't think #2673980 resolved the issue. On a fresh build of 8.9.* I'm still getting the error. Here's how I can create it.
* Fresh install of Drupal 8.9.x
* Add a link field to a content type. Allow it to contain external links
* Add content with external links in that field
* Create a view with a Feed display
* Format Show Fields
* Add the required fields (title, my link field, body, authored by authored on)
* Configure the row style options, with Content: my link field as the link field (and the rest as figured)
* Add a path and save
* Observe the following error when trying to access the feed url:
Comment #27
jrearickOkay. I took what @jennypanighetti did in #21 and re-rolled it for 8.9.x. I also found the same/similar issue if you use the link as the guid, so I added that in. Hopefully I formatted this patch correctly.
Comment #28
jrearickOf course a composer build doesn't give the right base for the patch file. Trying this one.
Comment #29
sivaji_ganesh_jojodae commentedComment #30
dwwAdding #3090267: Improve behaviour of RSS view with fields if you enabled "Use absolute link" as another related. That might be duplicate with this -- I didn't see this issue when I submitted that one as a follow-up to #2673980: RSS view with fields give wrong URL from path field.
No time to closely review all this just yet, but I'll try to look soon.
Thanks,
-Derek
Comment #31
xem8vfdh commentedI have the opposite problem. I set my RSS feed up years ago and it's worked fine while my RSS publisher published fully qualified URLS. They suddenly switched to publishing relative paths, and now my system broke with the same error in OP.
Comment #33
jennypanighetti commentedRe-rolled patch #28 for Drupal 8.8.x (starting from 8.8.5)
Comment #34
sivaji_ganesh_jojodae commentedThe patch couldn't be applied on 9.x.
Tagging "Needs tests" to confirm that the bug is present & needs a patch to fix.
Comment #35
vsujeetkumar commentedComment #36
vsujeetkumar commentedRe-roll patch created for 9.1.x, Please review.
Comment #37
ronaldmulero commented#36 works for me.
Thank you vsujeetkumar!
Drupal core 8.9.2
Configured the Link field of the View like this:

Comment #38
dww#36 is missing this hunk from #33, which should have been preserved.EDIT: Nope, sorry. This patch shouldn't touch that description (which I helped add!). Ignore this point.If the guid is an internal link, get the absolute URL from the URI.
#NeedsTests. ;)
Cheers,
-Derek
Comment #41
kasey_mk commentedThank you; #36 worked for me
Comment #42
vsujeetkumar commentedWorked on #38. Please have a look.
#38.1: Ignore this point as mentioned in #38.
#38.2: Changes has been done.
Comment #44
vsujeetkumar commentedRe-test the last patch, Moved to NR. Please have a look.
Comment #48
smustgrave commentedWas tagged for tests in #34 which still needs to happen.
Did not test patch.
Comment #49
omahm#42 Patch works for me (9.5.5 PHP 8.1) for a site running the Domain module. One caveat is that if you have Twig debugging enabled the field comments will passed into fromURI() which isn't a problem on production sites.
InvalidArgumentException: The URI ' <!-- THEME DEBUG --> <!-- THEME HOOK: 'views_view_field' --> <!-- BEGIN OUTPUT from 'core/themes/stable/templates/views/views-view-field.html.twig' -->Comment #51
douggreen commentedAttached patch is a small code cleanup to not duplicate calling
$this->getField($row_index, $this->options['link_field'])twice.Comment #52
douggreen commentedOops, this fixes a syntax error.
Comment #53
recrit commentedUpdated patch with further cleanup of duplicate calls to
$this->getField($row_index, $this->options['link_field'])Comment #54
recrit commentedThe attached patch will fix the errors with twig debugging enabled. Core without this patch would not error but would create urls were invalid - "http://www.mysite.com/%20%3C%21--%20THEME%20DEBUG%20--%3E%20%3C%21--%20T..."
Comment #55
recrit commentedPending: new test to test an external url used for the RSS link.
Comment #56
recrit commentedThe attached patches add the new feed field test to check field configured to output an absolute URL.
NOTE: The patch "2918784-55--fix-and-tests.patch" also applies to 10.1.x.
Comment #57
recrit commentedComment #58
smustgrave commentedIssue summary should be updated, not super clear what the proposed solution is.
Added the template to be filled in by someone familiar with the issue.
Removing tests tag as #56 shows they were added.
Comment #59
recrit commentedComment #60
recrit commentedComment #61
smustgrave commentedRemoving IS update tag as that was completed in #59
Following the steps in the IS I was able to reproduce the issue
Patch #58 did solve it, and reran the tests for php8.2 and think failure was unrelated.
Also tests-only patch was provided in #58 that shows the issue.
Think this one is good.
Comment #63
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue.
While you are making the above changes, we recommend that you convert this patch to a merge request. Merge requests are preferred over patches. Be sure to hide the old patch files as well. (Converting an issue to a merge request without other contributions to the issue will not receive credit.)
Comment #65
recrit commentedI created the following MRs: with 2918784-55--fix-and-tests.patch
11.x: MR 5437
10.1.x: MR 5438
Comment #67
longwaveAdded some feedback to the MR.
Comment #68
kasey_mk commentedI'm getting an error that
You are not allowed to specify an external URL together with internal:/. in Drupal\Core\Url::fromInternalUri()which is annoying because that's exactly what I want to do: our feeds may link to content on the same domain using theview_nodeinternal link to content, or on one of our other domains using a link field which may contain an external absolute link.The #15 fix on Improve behavior of RSS view with fields if you enabled "Use absolute link" lets me mix'n'match as I need to by allowing valid absolute links to pass right through the getAbsoluteUrl function.
There's obviously a lot more going on in this MR but I'm hoping that at the end of the day, I can be allowed to specify external URLs together with internal. Thanks!
Comment #69
recrit commentedthe following MR's have been updated per the MR feedback on MR 5438:
11.x: MR 5437
10.1.x: MR 5438
Comment #70
recrit commentedattached a 11.x static patch for composer builds
Comment #72
smustgrave commentedHiding the 10.1 so we just have the 11.x MR.
For the comments around using trim() and striptags()
If this is needed for the fix believe we maybe should have coverage also around when markup is used. To show that it is indeed needed.
Thanks.
Comment #73
jennypanighetti commentedI just upgraded to 10.3.x and it said the patch failed.. which one should I use for 10.3.1?
Comment #74
nicoleannevella commentedAny updates on this?
I'm using a Link field in an RSS feed view and have it set to display "link only" and "show URL as plain text" and I am still getting the error as drupal is expecting a relative link.
Can we not use absolute (external) urls in RSS feeds? I think that option should be available.
Using drupal 10.4.6