Closed (duplicate)
Project:
Drupal core
Version:
9.2.x-dev
Component:
entity system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
18 Mar 2015 at 16:56 UTC
Updated:
1 Feb 2021 at 12:25 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
dschenk commentedI'm working on this issue while sprinting in Barcelona.
Note that the rel attributes has defined keywords which we can use, see: http://www.w3.org/TR/html5/links.html#linkTypes. There is the possibility to propose new keywords, see http://microformats.org/wiki/existing-rel-values. But I don't think this is applicable here.
Will investigate this further.
Comment #2
dschenk commentedThe non-validating code is found in the HTML head of the node page when the user is allowed to edit it:
Comment #3
dschenk commentedThe code was introduced in https://www.drupal.org/node/2281645.
Comment #4
dschenk commentedUpdated summary with latest findings.
Comment #5
dschenk commentedComment #6
dschenk commentedComment #7
dschenk commentedComment #8
dschenk commentedMarked as duplicate of #2406533: edit-form, delete-form etc. <link> tags added on /node/{node} are invalid according to W3C Validator
Comment #9
duaelfrThe related issue only deals with some links, not all of them. Right now, the "revision" link is still there and still invalid.
Comment #10
duaelfrTo elaborate a bit, this is happening in
\Drupal\node\Controller\NodeViewController::view().The core, list all uriRelationships of the node (ie. everything in the "links" section of its annotation) then checks if the user has access to the given URL. The "revision" URL being translated the node URL when viewing the current revision, the user has access to it so this link tag is put in the head and it breaks the W3C validator.
Comment #12
slefevre1 commentedHello, it would be great to have a way to turn these off. I'm working on a site migration project, and I'm using link checker software to search for broken links. It finds these in the head and reports them as false negatives, because they return 403 forbidden (as the link checker is "browsing" as anonymous.)
Comment #14
edmonkey commentedI'm keen to see any progress on this or possible solutions, as W3 validation is a request/requirement of many govt/enterprise sites, so seems like good idea to make core validate as much as possible.
Comment #15
altback commentedI agree with @edmonkey here. Really looking forward to W3C valid html code.
Hoping that the issue is resolved soon.
Comment #16
vensiresUntil this issue gets resolved, anyone coming here could try the module Unset HTML Head Link.
Comment #17
saschahannes commentedI have filtered all valid tags in the uriRelationships method
Comment #18
saschahannes commentedPatch for drupal 8.8
Comment #19
saschahannes commentedUpdated patchfiles to fix ViewUI Error
Comment #20
saschahannes commentedComment #21
saschahannes commentedComment #22
saschahannes commentedUpdated test cases. Removed irrelevant test that is checking if node edit link will be shown.
Comment #23
anevins commentedRe-rolled this patch for 8.7.
Comment #24
anevins commentedRe-rolled 8.7 patch
Comment #25
anevins commentedRe-rolled 8.7 , this time with the correct naming conventions!
Comment #26
sphism commentedJust had a look at and the full list of rel values is:
A couple of those are obsolete...
Comment #28
marcoliverRerolled https://www.drupal.org/project/drupal/issues/2454915#comment-13151540 against 8.8.0
Comment #29
ducktape commentedRemoved the revision link from the test, as that one will get filtered out by this change.
Comment #30
mpp commentedAdd "."
Add "."
Add " " after comma.
Add " " after comma.
Add " " after comma.
Add " " after comma.
Comment #31
ducktape commentedFixed codestyle remarks.
Comment #33
joseph.olstadThanks to @ducktape,
Patch #31 also applies cleanly to Drupal 8.8.x
Patch #31 also applies cleanly to Drupal 9.0.x
Patch #31 also applies cleanly to Drupal 9.1.x
+1 for this! Thanks, we need this to pass w3c validation testing on https://validator.w3.org/nu/
for now we are adding this patch to our build
our build has a very long list of core patches now to which I will be pinging for status updates at some point.
Comment #34
mpp commented+1
Comment #35
larowlanIs there a reason we made this 'public' - I'm not sure we want to make this a public API.
we're comparing string here, so let's use the third argument here
these changes here are out of scope
these aren't valid English, but I don't think they add anything, so let's just leave these as
assertEmpty($result)and let phpunit generate its default messageComment #36
joseph.olstadVoilà c'est fait.
interdiff and new patch as per request.
Comment #37
joseph.olstadComment #38
gdaw commentedThanks for the quick turnaround joseph ... #36 works as well for us as #31 did. RTBC+1
Comment #39
andrewsuth commented+1 This patch works as expected, very good. The HTML output is now much cleaner and compliant.
Comment #40
joseph.olstad@larowlan, your suggested changes were added to the patch, is there anything left for us to do here? Or can this be committed right away?
Comment #42
ronaldmulero commented#36 fixes w3c validation error for me.
Thank you @joseph!
Drupal 8.9.7
Comment #43
dom. commented+1 any help needed anymore for inclusion ?
Adding #2467827: [META] W3C validation for Drupal Core as parent issue for reference.
Comment #44
vensiresComment #46
pameeela commentedClosed a duplicate so added credit for isholgueras.
Comment #47
larowlanThis looks ready to me, there's one suggestion here about type-hints, and finally a fix for type-safety with in_array
Fine to self RTBC those changes because they're minor
We can use a scale type-hint and a return-type here now (new code should use return/scalar types), ie
private function isValidRel(string $rel) : boolthe third argument here should be TRUE, these are strings, and the rel is a string, so we should be using the type-safe version
Comment #48
spokjeAddressed #47.1 and .2.
Comment #49
spokjeRTBC-ing myself feels weird, but also good... ;)
Comment #50
dom. commentedI used your patch and did not notice anything that was not expected.
However, reading the code, here are a few nitpicks I see. They are all about missing authorized rel attributes according to the documentation.
I suggest to include something like:
@see https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel
to offer a link to official documentation with listed valid attributes. Also following this documentation, some rels are missing in the list below.
dns-fetch exists here too. Should we include it ?
why not keep this alphabetically ?
"opener" also exists
"preconnect" also exists, as well as "prerender"
"search" is missing before
Comment #51
spokjeAll points raised by @Dom in #50 seem valid to me.
All addressed in attached patch.
Comment #52
dom. commentedAt least on my humble point of view: RTBC
Comment #53
joseph.olstadYes we are also using this for w3c compliance, thanks to everyone above.
Comment #54
larowlanNote to self: this won't cause disruption for implementations that extend NodeViewController because it is private
See https://3v4l.org/Q9UOD vs https://3v4l.org/Utcql
Saving issue credits
Comment #55
larowlanCommitted 9d4138c and pushed to 9.2.x. Thanks!
Moving to 9.1.x for possible backport, will get a second opinion
Comment #58
larowlanDiscussed this with @alexpott who pointed out there were two other issues where we'd decided not to fix this.
Linking those here.
Reverted in the meantime whilst we discuss those.
#2406533: edit-form, delete-form etc. <link> tags added on /node/{node} are invalid according to W3C Validator
Quoting @Dom. from #2468047-3: Header links makes extensive use of non W3C compliant rel attributes
Comment #59
dries commentedThe list at https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel is not complete.
There are
relattributes that are part of other standards. To name a handful:rel="webmention"rel="me"rel="shortlink",rel="syndication"andrel="micropub"rel="authorization_endpoint",rel="token_endpoint"andrel="microsub"rel="previous"andrel="payment"rel="hub"andrel="self"Long story short, I believe
isValidRel()needs to be removed. I'm bumping this to major as this most likely breaks dozens of contributed modules.Comment #60
dries commentedLooks like the patch was reverted so changing the priority back to 'Normal'.
Comment #61
spokjeEDIT: Snap! Crossing posts...
Nothing to see here, move along!
Most probably this is my last post on d.o. since I'm going to disagree with the BDFL @Dries here...
I'm expecting the unmarked vans to pull up across my house any minute now. 😉
As far as I can see
isValidRel()is introduced in this patch, so there's no Contrib depending on it, since Contrib doesn't know about it.So I think we can scale this down to priority "Normal" again?
(Not doing so, since I definitely don't want the people in the unmarked vans to pull out their stun guns...)
Comment #62
bserem commentedJust dropped by to say I loved comment #61 :)
Comment #63
jwilson3To address Dries' concerns, could the isValidRel() function be refactored a bit to move this hardcoded list to default config yaml so intrepid users could change to support the attribute values they want, and update the functions docblock so it is not tied to w3c (though our defaults would be the w3c ones)?
Comment #64
joseph.olstadI'm maybe missing something here but I don't consider the w3c as infallible so I'm open to other opinions. with that said we are using the patch just to please our wcag people and get them off our backs. Our org spends a lot of money on 'wcag experts', this doesn't mean I'm in 100% agreement with them all the time.
Comment #65
catchMarking duplicate of #2922570: The node view page triggers a lot of expensive access checks for relationship links which fixes the same issue in a different way (and is/was RTBC). I've transferred issue credit from this issue to that one.