-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix html encoding in LiquidViewFilters #7498
Conversation
@@ -107,7 +109,8 @@ static async ValueTask<FluidValue> Awaited(Task<IHtmlContent> task) | |||
StringValue value; | |||
using (var writer = new StringWriter()) | |||
{ | |||
task.Result.WriteTo(writer, NullHtmlEncoder.Default); | |||
var htmlEncoder = ShellScope.Services.GetRequiredService<HtmlEncoder>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use the AmbientValues of the context to get a service. Not the ShellScope.
Look at the ShortCodeFilter for an example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use the AmbientValues of the context to get a service. Not the ShellScope.
Is there any difference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not aware what the difference is, but it removes the need to depend on the ShellScope. I can only assume it allows for use in different contexts and also better testing (without having to implement a shell scope).
Before the regression, So currently, when In place of using
Or add the raw filter to prevent double encoding
Then we would have to update the layout in our themes. But stringify is intended to be used as a string not for direct rendering, e.g. to be passed as a parameter to another shape, so maybe before the regression there was another issue by encoding it. So, finally here i suggest to just replace
With
I tried it, it works for the related issue. |
I agree with the fact that |
@sebastienros It was written because we had issues with the Lucene/SQL Query templates (liquid). We needed something to get a raw value from a form posted value. |
Take a look at this sample: OrchardCore/src/OrchardCore.Themes/TheBlogTheme/Views/Content-BlogPost.Summary.liquid Lines 12 to 13 in 95b3301
It's using Update: |
Yes i saw this and tried it, here even we change it to Keep in mind that before #7463 that i did to fix an issue comented on gitter, Before the above commit there were both reurning a |
If no encoding is required I will close this PR |
@sebastienros about
Yes just tried, in fact here the raw is not applied to the dateTime argument, but to the whole, here this is the
But there was another issue on gitter where someone really want to work with the returned value expecting it is a string (not a That's why i did #7463 to really return a string, but unfortunately before the above commit I think there are other filters that wrongly return a string marked to be encoded, i'm thinking about those that generate urls, maybe currently it works because the browser is aware of this and html decodes them before url encoding them. |
Fixed by #7503 |
Fixed #7497
@jagbarcelo could please try the PR