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

Default table alignment triggers common Content Security Policy #12890

Closed
rtfmkiesel opened this issue Sep 29, 2024 · 4 comments
Closed

Default table alignment triggers common Content Security Policy #12890

rtfmkiesel opened this issue Sep 29, 2024 · 4 comments

Comments

@rtfmkiesel
Copy link

The default option for table alignments is 'left'. Would it be possible to exclude the style attribute altogether, if no : is used to indicate the alignment?

Having inline style tags triggers a CSP which does not allow for style-src 'unsafe-inline';.


What version of Hugo are you using (hugo version)?

$ hugo version
hugo v0.135.0-f30603c47f5205e30ef83c70419f57d7eb7175ab+extended windows/amd64 BuildDate=2024-09-27T13:17:08Z VendorInfo=gohugoio

Does this issue reproduce with the latest release?

Yes

@jmooring
Copy link
Member

jmooring commented Sep 29, 2024

This is a duplicate of #12886 which is resolved by #12889.

You can also control rendering of Markdown tables by creating a render hook. This will allow you to set left/right/center classes instead of using inline styles.

@rtfmkiesel
Copy link
Author

rtfmkiesel commented Sep 29, 2024

Thanks for the fast response, but it's not quite the issue I am describing.

Using your branch, I get the HTML of <td style=text-align:>test</td> when no : is used. This still triggers the CSP. The complete style attribute would need to be left out. Now, it's just an invalid style attribute.

Output: <td style=text-align:>test</td>
Expected: <td>test</td>

Applied wrong patch, ignore

@rtfmkiesel
Copy link
Author

The render hook workaround works, thanks for the hint!

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants