Skip to content
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

Textarea Macro Parameter Not Rendering HTML Markup #6286

Closed
bkclerke opened this issue Sep 5, 2019 · 8 comments
Closed

Textarea Macro Parameter Not Rendering HTML Markup #6286

bkclerke opened this issue Sep 5, 2019 · 8 comments
Labels
status/stale Marked as stale due to inactivity type/bug

Comments

@bkclerke
Copy link
Contributor

bkclerke commented Sep 5, 2019

In Umbraco v8, I am inserting a macro into the grid editor.

I am using a macro to embed a hubspot form code into a parameter that is a textarea called embed.

The macro itself just renders the embed code in the parameter like so: @Html.Raw(Model.MacroParameters["embed"])

The output of this is literally printing the html markup that I put into the macro parameter.

If I output just the parameter without Html.Raw then I get the decoded markup printed out. ( & instead of "&")

When I tested just entering this macro into the RTE, the macro disappears on save.

I was able to do this in previous versions of Umbraco just fine but it seems that I can no longer do this in v8. I posted this on our as well.


This item has been added to our backlog AB#2540

@nul800sebastiaan
Copy link
Member

Thanks @bkclerke - I can reproduce the error. Now to find the cause... 🙈

@gopkumr
Copy link
Contributor

gopkumr commented Sep 6, 2019

@bkclerke the macro parameter value is stored encoded and hence when you use the @Html.Raw(..) it renders the html mark up. As a workaround i tried performing a decode before passing it onto the Raw function and i was able to render the HTML form. Below is the code i used.
@Html.Raw(System.Web.HttpUtility.HtmlDecode(Convert.ToString(Model.MacroParameters["embed"])))

PS:Not a good one, but might able to help you until the bug is resolved.

I couldn't manage to get the backoffice showing the form render but the webpage shows it right.

Hope this helps.

@stevemegson
Copy link
Contributor

It looks like the attribute values need to be decoded in either RteMacroRenderingValueConverter.RenderRteMacros or MacroTagParser.ParseMacro, I'm not sure if there's any reason to prefer one over the other.

@nul800sebastiaan
Copy link
Member

The thing I'm afraid of now is when we do fix this that workarounds like the one above are going to break your site(s) 🤔

Or maybe double-decoding could work fine. Not sure.

@gopkumr
Copy link
Contributor

gopkumr commented Sep 6, 2019

@nul800sebastiaan double decoding works, doesn't break. If it doesn't find anything to decode,it just returns the string as is.

@stevemegson
Copy link
Contributor

That depends what the original parameter value was. If it was HTML containing encoded things, double decoding could break it.

It could also be a breaking change if people are unknowingly relying on the HTML encoding for other parameters that don't contain HTML. You might have written @Html.Raw(Model.MacroParameters["title"]) because @Model.MacroParameters["title"] was coming out double-encoded, without really recognising that this was a workaround for a bug.

@bkclerke
Copy link
Contributor Author

bkclerke commented Sep 6, 2019

Thank you!! && @gopkumr thank you for the work around! I've actually hard coded the form for now since the site is launching on Tuesday. I'll definitely be keeping an eye out for fixes though, I plan to upgrade the site and I can add this macro back in for future features. :)

@umbrabot
Copy link

umbrabot commented Mar 3, 2021

Hiya @bkclerke,

Just wanted to let you know that we noticed that this issue got a bit stale and might not be relevant any more.

We will close this issue for now but we're happy to open it up again if you think it's still relevant (for example: it's a feature request that's not yet implemented, or it's a bug that's not yet been fixed).

To open it this issue up again, you can write @umbrabot still relevant in a new comment as the first line. It would be super helpful for us if on the next line you could let us know why you think it's still relevant.

For example:

@umbrabot still relevant
This bug can still be reproduced in version x.y.z

This will reopen the issue in the next few hours.

Thanks, from your friendly Umbraco GitHub bot 🤖 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/stale Marked as stale due to inactivity type/bug
Projects
None yet
Development

No branches or pull requests

7 participants