Closed (won't fix)
Project:
Drupal core
Version:
8.0.x-dev
Component:
field system
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
10 Jul 2012 at 22:17 UTC
Updated:
29 Jul 2014 at 20:52 UTC
Jump to comment: Most recent file
Comments
Comment #0.0
alexander allen commentedspecified text-fields
Comment #0.1
alexander allen commentedThis is because Views honors the Field API formatters provided by the modules that expose the fields. Mod last paragraph.
Comment #0.2
alexander allen commentedBreak into new paragraph
Comment #0.3
alexander allen commentedIf a core maintainer thinks a raw formatter contrib module would be better, I'm open to exploring that option as well.
Comment #0.4
alexander allen commentedEnterprise users using Drupal to export data to other services via Views and other contrib modules might need their content in it's origina form (as they entered it), but will find that all their content is being escaped.
Comment #0.5
alexander allen commentedmissed an l
Comment #1
marcingy commentedThis sounds a feature request and has to go into d8 first and be backported
Comment #2
alexander allen commentedSounds good marcingy, thanks for the update.
Comment #3
alexander allen commentedAttached patch for 8.x.
Screenshot of testing with Views:
Comment #3.0
alexander allen commentedThis functionality is necessary in order to integrate Drupal with (some) third-party services...
Comment #4
alexander allen commentedModifying neither hook_field_info() or hook_field_instance_settings_form() was necessary. Providing the new formatter through text_field_formatter_info() was enough for the "Raw text" format to show up on the Views formatter drop down.
Uploaded new patch.
Comment #4.0
alexander allen commented1) Formatters are expoed by hook_field_formatter_info(), not hook_field_info()! 2) Formatters are intrinsic to the module that creates the field, a "raw formatter" contrib module wouldn't be of any use (I was contradicting myself w/ this suggestion).
Comment #5
swentel commentedRerolled for the new plugin system + added tests.
I'm not sure whether we'll ever get this in core because of potential security issues here - although it's easy to configure your site wrong with text formats too.
It's a formatter I probably write for every project though, so it would be handy to be in core :)
Comment #6
swentel commentedWoops, empty patch.
Comment #7
yched commentedHmm, a 'raw' formatter in core that you can "simply" select and give up security sounds like a pushing a loaded gun in the hands of unaware users...
The use cases mentioned in the OP are, well, legit, but sound edge case enough that shipping this in core sounds questionable given the security impact - besides, D8 will have other solutions for data export than views spitting formatter-based output.
Bumping over to sun to get his opinion.
Comment #8
sunOy. ;) So yeah... this is kind of The Ultimate Way To Hose Your Site™ :)
Based on technical grounds only, this formatter would have to be limited to text fields that do not have text processing enabled. In other words: If there is a text format assigned to a text field value, then there must not be a way to output the raw user input without filtering.
I don't know whether Field API is capable of doing that; i.e., limiting a formatter to sub-variants of field types.
I'm also not sure whether that's all that would be required. I think we'd additionally need to introduce security warnings in a couple of places, so as to inform the user that "Howdy, this is not a good idea, because... Press the Confirm button if you are really sure you want to do this, or Cancel to reset to a previous/safe configuration."
Now on to the logical side...
I don't think I understand the use-case. ;) You surely do not want to render any user input without escaping/sanitization/filtering potential XSS and CSRF, right?
I can only assume that the actual use-cases boil down to text fields that are only exposed to site administrators/builders, which in turn means that you believe that you're safe and exempt from any attacks, because, well, you entered that HTML yourself. Is that a fair understanding? :)
Let's make sure to clarify the actual use-case for this first.
But in general, if aforementioned assumption is the case, then I would actually recommend to forget about the entire text field/formatter integration, and instead, introduce an entirely new HTML field type. That makes clear that the user input is expected to be raw HTML and the field's entire purpose is to output raw HTML. Also no danger of unintentionally outputting user input that ought to be filtered. And access to the field could even be controlled through specialized access permissions. Would that make sense?
Comment #9
sunThanks for notifying.
Comment #10
yched commented@sun : regarding use case, see the OP
This is IMO the only valid use case, and basically in #7 my take on that was :
- Too edge case for core, given the security implications for 99% unsavvy users
- D8 will have better tools for data export
Comment #11
sunSo hm... pure export.
If we were able to differentiate between the final output format of a rendered entity or view, and thus, if we could be sure that the raw formatter wouldn't be used on an HTML page, but only when rendering into XML/RSS, JSON, etc.pp., then I could see this working for core. But I guess that's a very long shot...
Comment #12
yched commentedWe have no way to qualify view modes (HTML, export-only), and we have no way to force a formatter to be available on some view modes only, so yeah, the premises in #11 look out of reach.
I guess that's a "won't fix", then... @Swentel, what do you think ?
Comment #13
swentel commentedYeah, this is contrib material :)
Comment #14
yched commentedPinged the fine folks in #1819760: Add a REST export display plugin and serializer integration., which aims at getting a JSON (non JSON-LD) output for views.
Comment #14.0
yched commentedI found out that you can use hook_field_formatter_info() + hook_field_formatter_view() to support field formatters in Views.