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

Using Qute asHtmlAttributes is escaping the quotes in the output #38251

Closed
ia3andy opened this issue Jan 17, 2024 · 8 comments · Fixed by #38255
Closed

Using Qute asHtmlAttributes is escaping the quotes in the output #38251

ia3andy opened this issue Jan 17, 2024 · 8 comments · Fixed by #38255
Assignees
Labels
area/qute The template engine kind/bug Something isn't working
Milestone

Comments

@ia3andy
Copy link
Contributor

ia3andy commented Jan 17, 2024

Describe the bug

Using Qute asHtmlAttributes is escaping the quotes in the output:

<form action="{it}" method="{method ?: 'POST'}" {_args.skip('method', 'it').asHtmlAttributes}>
 {#authenticityToken/}
 {nested-content}
</form>

The workaround is to use: asHtmlAttributes.safe

Expected behavior

<form action="/HtmxApp/save/6" method="POST" hx-put="/HtmxApp/save/6" hx-swap="&quot;outerHTML&quot;" hx-target="this">

I believe the value (inside the quote) should be escaped

Actual behavior

<form action="/HtmxApp/save/6" method="POST" hx-put="&quot;/HtmxApp/save/6&quot;" hx-swap="&quot;outerHTML&quot;" hx-target="&quot;this&quot;"
">

How to Reproduce?

No response

Output of uname -a or ver

No response

Output of java -version

No response

Quarkus version or git rev

3.6.5

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

@ia3andy ia3andy added the kind/bug Something isn't working label Jan 17, 2024
@quarkus-bot quarkus-bot bot added the area/qute The template engine label Jan 17, 2024
Copy link

quarkus-bot bot commented Jan 17, 2024

/cc @mkouba (qute)

@mkouba mkouba self-assigned this Jan 17, 2024
@mkouba
Copy link
Contributor

mkouba commented Jan 17, 2024

The is straightforward, except that we must change the return type of the UserTagSectionHelper.Arguments.asHtmlAttributes() method from String to RawString. As a consequence, a user will need to use {_args.asHtmlAttributes.value} to access the String methods... which I believe is not a big deal.

@ia3andy
Copy link
Contributor Author

ia3andy commented Jan 17, 2024

@mkouba you need to update the doc

@mkouba
Copy link
Contributor

mkouba commented Jan 18, 2024

Oh yes, we could mention that the values are always escaped but other than that the docs is IMO ok.

@ia3andy
Copy link
Contributor Author

ia3andy commented Jan 18, 2024

Oh yes, we could mention that the values are always escaped but other than that the docs is IMO ok.

@mkouba I mean for the {_args.asHtmlAttributes.value}. See https://quarkus.io/guides/qute-reference#arguments

@mkouba
Copy link
Contributor

mkouba commented Jan 18, 2024

Oh yes, we could mention that the values are always escaped but other than that the docs is IMO ok.

@mkouba I mean for the {_args.asHtmlAttributes.value}. See https://quarkus.io/guides/qute-reference#arguments

Well, I think that 99% of users will never need {_args.asHtmlAttributes.value} but it wouldn't hurt to be more specific.

@ia3andy
Copy link
Contributor Author

ia3andy commented Jan 18, 2024

@mkouba so _args.asHtmlAttributes actually works as it is? I just misunderstood what you mean before by "to use it as a String", if that's the case, you can ignore my comment :)

@mkouba
Copy link
Contributor

mkouba commented Jan 18, 2024

@mkouba so _args.asHtmlAttributes actually works as it is? I just misunderstood what you mean before by "to use it as a String", if that's the case, you can ignore my comment :)

Yes, it does. But you get a RawString instead. So for example {_args.asHtmlAttributes.toUpperCase} would not work but it used to work before... (now you would need to use {_args.asHtmlAttributes.value.toUpperCase})

bpasson pushed a commit to bpasson/quarkus that referenced this issue Jan 18, 2024
@gsmet gsmet modified the milestones: 3.9 - main, 3.7.0 Jan 23, 2024
gsmet pushed a commit to gsmet/quarkus that referenced this issue Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/qute The template engine kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants