Closed (duplicate)
Project:
Drupal core
Version:
8.0.x-dev
Component:
theme system
Priority:
Major
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
6 Jun 2015 at 19:41 UTC
Updated:
24 Jul 2015 at 17:49 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
dani3lr0se commentedMy very first patch! Hopefully this helps.
Comment #2
dani3lr0se commentedComment #3
dani3lr0se commentedComment #4
star-szrThanks @Daniel_Rose!
Maybe this could be something along the lines of:
"Theme functions do not go through Twig so the output is not autoescaped. Theme function output is always expected to be 100% safe."
Undo these changes :)
Comment #5
dani3lr0se commentedThanks for the feedback @Cottser! How does this look?
Comment #6
dani3lr0se commentedComment #7
dani3lr0se commentedOops. My apologies. I realized that I didn't actually undo all of those changes in #2 in your comment @Cottser. Hopefully this looks a little better.
Comment #8
ultimikeLooks ready to go.
-mike
Comment #9
star-szrI think the comment should live right above the SafeMarkup::set(), like the other issues have done.
Comment #10
dani3lr0se commentedHow's this look?
Comment #11
dani3lr0se commentedComment #12
akalata commentedThe patch itself looks fine, though I have a slight issue with the wording of the comment -- I'd prefer the "is presumed to be safe" over the "is always expected to be safe", unless there is a test somewhere that confirms the expectation? Are there internal requirements that any theme function is guaranteed to be safe, or are we only presuming that this will be the case?
Just thinking in terms of the precision of uncertainty -- will keep as Needs Review and ping a theme system expert to review.
Comment #13
star-szr@akalata very good point I would tend to agree the wording could be more precise.
Comment #14
akalata commentedComment #15
akalata commentedI've updated our language a bit, which hopefully more clearly indicates the responsibility of the writer of the theme function (since the ones left in core are few and far between). I'm not sure if this is a documented standard or best practice, but it probably should be (even if my proposed standard is completely wrong). Quoting dawehner in IRC: "we output the string here, so we should sanitize it here".
Comment #16
davidhernandezI believe we use autoescape as one work, not with a hyphen. Otherwise, looks fine.
Comment #17
akalata commentedComment #18
davidhernandezComment #19
dani3lr0se commentedI like it, but would it make more sense to say:
//Theme functions do not render via the "Twig template engine"....Instead of just saying "the theme engine.."
Especially since the "PHPTemplate" engine is still in the engines folder?
Comment #20
davidhernandez"theme engine" is more generic. Theme functions would not render using phptemplate either.
Comment #21
dani3lr0se commentedThat makes sense. I was thinking that might also be the case, but wasn't 100% sure. I've been reading through every document and resource I could find about theme functions via Twig, etc., and a lot of it made sense, but some seemed contradictory. This stuff is awesome. Much to learn though.
Patch looks good to go then. Thanks all for the feedback and help! What would be the next step in this process? Do we need more reviewing and testing?
Comment #22
xjmThanks folks for the patch! I think the current wording is good. However, I actually feel like we should be trying to remove this call.
@alexpott suggested postponing this on #2506581: Remove SafeMarkup::set() from Renderer::doRender, which is the only place that uses
theme()directly. So doing that now.Comment #23
lauriiiUnpostoponing
Comment #24
dawehnerSo yeah I think the proper way is to return a safe string. This also removes a bit of the memory overhead we do have.
Comment #25
cmanalansan commentedRemoved SafeMarkup::set(), and added additional explanation:
Comment #26
cmanalansan commented@davidhernandez (yelling at someone else):
Comment #28
cmanalansan commentedWe are going to fix this in #2501931: Remove SafeMarkup::set in twig_render_template() and ThemeManager and FieldPluginBase:advancedRender, so I am marking as duplicate.