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

Use IHtmlGenerator / TagBuilder in all necessary tag helpers #5322

Closed
SecTex opened this issue Sep 7, 2020 · 5 comments · Fixed by #5331
Closed

Use IHtmlGenerator / TagBuilder in all necessary tag helpers #5322

SecTex opened this issue Sep 7, 2020 · 5 comments · Fixed by #5331
Assignees
Milestone

Comments

@SecTex
Copy link
Contributor

SecTex commented Sep 7, 2020

Hi,

Is there a reason that some attribute values are not encoded when using abp's tag-helper?
If not, I would like to contribute a PR.

Background:
We want to give the user the opportunity to edit the localized texts. Accordingly, the values should be encoded.

Example:

✔️ Properly encoded

<abp-button button-type="Primary">@L["Edit"].Value</abp-button>

❌ Not encoded

<abp-button button-type="Primary" text="@L["Edit"].Value"></abp-button>
@maliming
Copy link
Member

maliming commented Sep 7, 2020

I think this is the behavior of Razor Pages.

@SecTex
Copy link
Contributor Author

SecTex commented Sep 7, 2020

I don't think so.
Another example when using AbpTabLinkTagHelper:

input:

@{ 
    var test = "\"><img src=0 onerror=alert(0)>";
}
<abp-tabs>
    <abp-tab-link title="Link" href="@test"/>
</abp-tabs>

expected result:

<a class="nav-link active" id="...-tab" href="&quot;><img src=0 onerror=alert(0)>">Link</a>

actual result:

<a class="nav-link active" id="...-tab" href=""><img src="0" onerror="alert(0)">"&gt;Link</a>

Therefore I have to encode the value test by myself, while the default tag-helpers handle encoding for me:
input:

@{ 
    var test = "\"><img src=0 onerror=alert(0)>";
}
<a asp-host="@test">Click Me</a>

actual result:

<a href="http://&quot;><img src=0 onerror=alert(0)>">Click Me</a>

@SecTex
Copy link
Contributor Author

SecTex commented Sep 7, 2020

Also, I would like to an fix an issue in jquery-extensions.js.
jQuery's html()-function is used in line 38 and 58. I recommend to use text() instead.

@maliming maliming self-assigned this Sep 8, 2020
@maliming maliming added this to the 3.2 milestone Sep 8, 2020
@maliming maliming changed the title abp tag helper - html encoding Use IHtmlGenerator in all necessary tag helpers Sep 8, 2020
@SecTex
Copy link
Contributor Author

SecTex commented Sep 8, 2020

Hi @maliming,

Is there a reason why you want to use IHtmlGenerator?
Another possibility would be to use the TagBuilder class. For example: e25cd9c

@maliming
Copy link
Member

maliming commented Sep 8, 2020

hi @SecTex

I just check the AspNet Core tag helper source code, not depth study. TagBuilder seems fine.

@maliming maliming changed the title Use IHtmlGenerator in all necessary tag helpers Use IHtmlGenerator / TagBuilder in all necessary tag helpers Sep 9, 2020
@maliming maliming modified the milestones: 3.2, 3.3 Sep 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants