mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2026-04-25 09:16:02 +03:00
[GH-ISSUE #464] MD033: Add option to allow or prohibit html attributes #2232
Labels
No labels
bug
enhancement
enhancement
enhancement
fixed in next
fixed in next
fixed in next
new rule
new rule
new rule
pull-request
question
refactoring
refactoring
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/markdownlint#2232
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @FrancisVila on GitHub (Dec 9, 2021).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/464
I'd like to set the markdownlint.json file so that it allows HTML tags such as
<table>,<tr>,<td>... tags, but prohibits any attributes likeonclickoronmouseover. I've found the"MD033": { "allowed_elements": ["table", "tr"]}entry, but no way of banning or allowing specific attributes within those tags.I would like to have something like:
Why: I want to avoid the risk of accidentally letting through malicious code inside Pull Requests. I'm also converting docs from XHTML generated by Madcap Flare into markdown. Some of the tables are complex, with tables inside tables, multiple uses of colspan and rowspan. I am setting aside such tables from the conversion process (I'm using pypandoc in python, a thin wrapper for pandoc).
@DavidAnson commented on GitHub (Dec 9, 2021):
You may be able to block "onclick" today via MD044 by saying the preferred form is "OnClIcK": https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md044---proper-names-should-have-the-correct-capitalization
@FrancisVila commented on GitHub (Dec 10, 2021):
Thanks, I'll try that!
@FrancisVila commented on GitHub (Dec 10, 2021):
Yes,
'MD044': {'names': ['OnClIcK']},does issue a warning for<a href="#" onclick="alert('HHHH')">AAA</a>BUT
<a href="#" OnClIcK="alert('toto')">EEEEEEEEEEE</a>produces an alert, the same as
<a href="#" onclick="alert('toto')">EEEEEEEEEEE</a>So someone knowing the trick could look up the
.markdownlintfile and check the specified capitalization...@DavidAnson commented on GitHub (Dec 10, 2021):
Someone who wants to bypass the rules can disable them with a comment. :) The linter is meant to help well-meaning people and is not a security boundary.
@FrancisVila commented on GitHub (Dec 10, 2021):
Thanks David, I'll use that argument to justify adapting the .markdownlint file in my repo.