Problem/Motivation
The template_preprocess_file_link()
should not add various metadata attributes. It currently adds the mime type and file size into the type parameter.
The code where this is added links to the following page: http://microformats.org/wiki/file-format-examples
This format is given as an example of how this type of data has been added in other places, but is not proposed as a microformat.
Further the HTML spec formally specifies the type parameter to the a element, and says that it can only contain the mime type of the file.
Proposed resolution
Therefore we should either remove the type parameter all together, or continue to add it, but only include the mime type.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#21 | interdiff_12_20.txt | 501 bytes | ultrabob |
#21 | 2991219-20-D_9_1_x.patch | 690 bytes | ultrabob |
#12 | 2991219-12-D_9_1_x.patch | 642 bytes | nitesh624 |
#3 | drupal-remove-microformat-data-from-file-link-2991219-3-D8.patch | 1004 bytes | SchnWalter |
Comments
Comment #2
SchnWalter CreditAttribution: SchnWalter as a volunteer and commentedComment #3
SchnWalter CreditAttribution: SchnWalter as a volunteer and commentedFixed patch.
Comment #7
Kristen PolPatch applies cleanly to 9.1.x.
Comment #8
Kristen PolThanks for the issue and patch.
1) Code changes are straightforward.
2) Marking for manual testing.
3) Kicking of tests for 9.1.x.
Comment #9
tanubansal CreditAttribution: tanubansal at Salsa Digital commentedNeed a patch for 9.1
Comment #10
Kristen PolComment #11
nitesh624I'm working on it, will update in few hours.
Comment #12
nitesh624Rerolled the patch
Comment #13
nitesh624Tested manually in my system, seems to be working file.
Comment #14
Kristen PolFor historical context, this is from git blame:
so the comment is from 2009 and the code was last updated in 2014 trivially as so:
Comment #15
Kristen PolI'm trying to understand why this should be removed. The issue summary doesn't explain why, just that it should be removed.
Comment #16
Kristen PolI have tested with and without the patch and it works as expected. I'm just unclear why it should be removed. I see it defined here as well: https://www.w3.org/TR/html4/struct/links.html#adef-type-A and https://www.w3.org/TR/2011/WD-html5-author-20110809/the-link-element.htm....
Comment #17
jungleSee https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a
See https://developer.mozilla.org/en-US/docs/Glossary/MIME_type
Per the docs for the
a
tag, I think<a href="URL" type="text/plain">A file</a>
is good. But<a href="URL" type="text/plain; length:1024">A file</a>
with length appended is not good. 1)length
is not a part oftype
obviously, and 2) maybe it's not good for security leaking the file size? -- one can see the url, but no access to the file.So to me, this issue could be removing the
length
metadata from thetype
. Removing the whole type attribute does not make sense to me.Comment #18
ultrabob CreditAttribution: ultrabob commentedTo clarify a bit. The problematic output is not the microformat. It is, I believe, an alternate solution highlighted in the page linked in the git blame. In any case, I agree that adding file details into the type field is not likely to be expected by anyone, and agree that it should not be added by default. As @jungle mentions, there is nothing wrong with including the type parameter with a mimetype.
Looking at the w3c HTML 5 working draft for web authors (https://www.w3.org/TR/2011/WD-html5-author-20110809/links.html#hyperlink) I find the following text:
So clearly the file size and other info doesn't belong there.
I guess the main question left about this issue is whether the type should be inserted there or not.
Comment #19
ultrabob CreditAttribution: ultrabob commentedPersonally I think if we have the mimetype there already we may as well use it. I'll upload a tiny change to the patch to reenable the mimetype shortly.
Comment #20
Kristen PolRight. Well if we have two patches, one that removes all from above and a new one that just removes the length then the core maintainers could choose which patch to use. Thanks to you both for the input.
Comment #21
ultrabob CreditAttribution: ultrabob commentedAdding the mime-type back in without the file size.
Comment #22
ultrabob CreditAttribution: ultrabob commentedSorry, I got my comment number wrong, but exactly as #20 mentions. We now have the choice of two approaches.
Comment #23
Kristen PolThanks for the patch. Marking RTBC since:
1) Code looks fine.
2) Tests pass.
3) Works as expected. See screenshot.
4) Maintainers can choose between patch in #12 that removes the type completely or #21 which only removes the
length
data.Comment #24
Kristen PolWhoops.
Comment #26
jungleA known random fail. Re-queued.
Comment #27
larowlanCan we get an issue summary update detailing why we are doing this? It's not clear to me from reading the comments.
The microformats wiki still has examples that reference file size
Comment #28
Kristen PolI'm not sure but, if I'm understanding this correctly, then only Firefox has built-in support and some other browsers support it with an extension:
http://microformats.org/wiki/browsers
Comment #29
ultrabob CreditAttribution: ultrabob commentedUnless I’m completely misunderstanding the page at http://microformats.org/wiki/file-format-examples, this is not even a micro format as proposed by micro formats.org. That is either how it has been observed having been done or one of the existing suggestions for how it could be done. The example of this format is in the other attempts to solve the problem section, not any kind of micro format definition.
In short, I don’t think this format is even a defined micro format, and I’m not sure why it ever got added. Type is an officially defined HTML parameter for a tags. The definition says that if it is there, it should contain the mime type. There seems to be no wiggle from for a file micro format to be defined using that parameter.
Comment #30
ultrabob CreditAttribution: ultrabob commentedAs a spot check, I did a quick browse through
the php-mf2 Codebase including the list of mf1 formats it parses, and could find no evidence that it would pick up and parse the type parameter as a micro format at all.
Comment #31
Kristen Pol@ultrabob Thanks for the info. Would you update the issue summary with the justification for switching this? Sounds like you have a good handle on it. :)
Comment #32
ultrabob CreditAttribution: ultrabob commentedComment #33
ultrabob CreditAttribution: ultrabob commentedComment #34
jungleThanks @ultrabob, applying the IS template and setting back to RTBC.
Comment #35
larowlanAs we're removing something here, I think we need to communicate this via a change record.
Tagging as such.
Comment #36
partyka CreditAttribution: partyka at Argonne National Laboratory commentedAdded change record: https://www.drupal.org/node/3163231
Comment #37
Kristen PolThanks for the change record.
1) Note that the change record is for just removing the size and not removing the type.
2) Assuming that's ok, I'm not sure if change records ever include quotes in them but I'll leave that. I did add an example.
Back to RTBC.
Comment #38
partyka CreditAttribution: partyka at Argonne National Laboratory commented@Kirsten Pol -- I only added it as a quote because I thought it summed up the justification perfectly, and didn't want to take credit for that wording :-)
Comment #39
Kristen PolAgreed, great quote :) just don't know if it's customary or not in change records.
Comment #40
larowlanCrediting @jungle for taking part in the discussion and @partyka for the change notice.
Comment #42
larowlanCommitted d7d9ebd and pushed to 9.1.x. Thanks!
Amended and published the change record.
Because there is a slight chance of disruption here (someone may be depending on this feature, as odd as it is), not going to put this forward for backport. In addition, its only a minor bug, so there's not huge demand for it to be backported.