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

Width and alignment of RST images #114

Merged
merged 2 commits into from
Jul 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions readme_renderer/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,17 @@
# Custom Additions
"*": ["id"],
"hr": ["class"],
"img": ["src", "width", "height", "alt", "align"],
"img": ["src", "width", "height", "alt", "align", "class", "style"],
"span": ["class"],
"th": ["align"],
"td": ["align"],
"code": ["class"],
"p": ["align"],
}

ALLOWED_STYLES = []
ALLOWED_STYLES = [
"width", "height",
]


def clean(html, tags=None, attributes=None, styles=None):
Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/test_CommonMark_style.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<img src="https://example.com/badge.png" style="width: 20px; height: 20px;">
1 change: 1 addition & 0 deletions tests/fixtures/test_CommonMark_style.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<img src="https://example.com/badge.png" style="width: 20px; height: 20px; color:red;">
1 change: 1 addition & 0 deletions tests/fixtures/test_GFM_style.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<img src="https://example.com/badge.png" style="width: 20px; height: 20px;">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I hadn't looked at the code changes before, this isn't going to work on PyPI, we don't allow inline styles via CSP, so anything that relies on the style attribute is not going to work, and I would be a hard -1 on relaxing our CSP rules to allow it.

1 change: 1 addition & 0 deletions tests/fixtures/test_GFM_style.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<img src="https://example.com/badge.png" style="width: 20px; height: 20px; color:red;">
2 changes: 1 addition & 1 deletion tests/fixtures/test_rst_png_attrs.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<img alt="alternate text" src="https://example.com/badge.png">
<img alt="alternate text" class="align-right" src="https://example.com/badge.png" style="width: 25.0%; height: 100px;">
2 changes: 1 addition & 1 deletion tests/fixtures/test_rst_svg_attrs.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<img alt="alternate text" src="https://example.com/badge.svg">
<img alt="alternate text" class="align-right" src="https://example.com/badge.svg" style="width: 25.0%; height: 100px;">