Re:Show HN: Generate styled web pages with just Python
by akx on Wednesday March 22, 2023 @04:13AM
(#35258182)
Mmm, looks like the library doesn't do any escaping for content (and doesn't offer a way to do that either)?
[ Parent
| on HN ]
Re:Show HN: Generate styled web pages with just Python
by ashishsingal on Wednesday March 22, 2023 @06:35AM
(#35259129)
what do you mean by "escaping for content"?
Re:Show HN: Generate styled web pages with just Python
by gvx on Wednesday March 22, 2023 @07:10AM
(#35259361)
I think what they mean is that methods like add_header and add_text actually take raw HTML as an argument, which means that if you want to add arbitrary text, you actually need to do
import html
...
card.add_text(html.escape(my_text))
Re:Show HN: Generate styled web pages with just Python
by zainhoda on Wednesday March 22, 2023 @07:55AM
(#35259684)
That’s correct. Perhaps I should add some documentation around this. Untrusted user input needs to be sanitized before using it in the page.
Re:Show HN: Generate styled web pages with just Python
by pbronez on Wednesday March 22, 2023 @08:22AM
(#35259956)
Seems like that should just be a warning in the docs, since mostly we’re talking about trusted code written by the dev…. Although maybe that’s untrusted from your perspective as a PaaS?
What’s the escape hatch to write custom HTML in the Python source?
Re:Show HN: Generate styled web pages with just Python
by ashishsingal on Wednesday March 22, 2023 @08:59AM
(#35260308)
there's "HTML (.add_html)" in the docs - "Renders raw HTML. This is meant to be an escape hatch for when you need to render something that isn't supported by PyVibe." I'm guessing this isn't sanitized and we trust the dev. After all, they can do "eval" in Python which is much riskier than raw HTML :)