-
Notifications
You must be signed in to change notification settings - Fork 26
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
Epic: Correct escaping in HTML output #1920
Comments
Thanks for reporting this. It is a lack of feature 😄 The html.escape was implemented for multiline fields but not for single-line. Let's implement it for single-line as well. |
IIUC multiline was implemented for the UI forms in #1018. Multiline in static views (like components/requirement/index.jinja) is escaped too, but for a different reason: We pipe it through docutils, which does escaping under the hood. I thought about when and where is the best place to do the escaping:
I'd probably start by trying automatic escaping and see how it works out. Do you have an opinion? |
Sorry for the delays with my responses, I am running low on my free time. I think I would prefer the If we used |
No hurry. Same here.
I did some trials with Jinja2 autoescaping already yesterday and wanted to present it first before discarding the idea. Therefore #1921. If you don't agree with the reasoning just close that MR and let's continue discussion here. |
I have added a few TODOs here but let's consider them a very low priority. You/I don't have to rush into completing them all as long as your use case is working. I would just like to have more test coverage to make sure we didn't miss any screens just in case. StrictDoc has many such low-priority tickets which all would love attention, so let's move according to what stands out most. |
There were some occurrences of " " in Python statements within Jinja2 templates. They must be marked as safe, otherwise they would be rendered to literal by auto escaping. This happened in diff screen for any text nodes, and sections with LEVEL: None, as well as in TOCs for sections with LEVEL: None. Relates to strictdoc-project#1920.
There were some occurrences of " " in Python statements within Jinja2 templates. They must be marked as safe, otherwise they would be rendered to literal by auto escaping. This happened in diff screen for any text node, and sections with LEVEL: None, as well as in TOCs for sections with LEVEL: None. Relates to strictdoc-project#1920.
It turns out that the search feature has regressed due to the autoescaping: |
Will have a look, hopefully tomorrow. |
Hm, can't reproduce... When typing
This looks OK and works. How did you test it? |
Good to know that the search screen itself is not affected. My testing was around the links that are on the statistics screen: http://127.0.0.1:5111/project_statistics.html. The legend has escaped/broken hrefs. |
Search URLs generated for the project statistic page were caught by Jinja2 autoescaping, which makes them invalid. A good place to mark them as safe is the view object: It's the immediate layer below Jinja templates and specifically made to provide strings included by a Jinja2 template. Relates to strictdoc-project#1920.
Search URLs generated for the project statistic page were caught by Jinja2 autoescaping, which makes them invalid. A good place to mark them as safe is the view object: It's the immediate layer below Jinja templates and specifically made to provide strings included by a Jinja2 template. Relates to strictdoc-project#1920.
For HTML escaping of the diff view we have to consider two things. 1. Diff input comes from two git checkouts of the project at specific revisions. The revisions sdocs are considered untrusted user input, could contain special characters and must be escaped. 2. After analyzing with difflib we add a bit HTML to colorize the output. This specific HTML fragments are trusted and safe. Relates to strictdoc-project#1920.
For HTML escaping of the diff view we have to consider two things. 1. Diff input comes from two git checkouts of the project at specific revisions. The revisions sdocs are considered untrusted user input, could contain special characters and must be escaped. 2. After analyzing with difflib we add a bit HTML to colorize the output. This specific HTML fragments are trusted and safe. Relates to strictdoc-project#1920.
I think, now we can close this one 😄 Thanks @haxtibal for supporting this. |
To reproduce, generate an html export of the following document
I assume this is a bug, not a feature...
html.escape
is already used in some places. I'll have a look and try to catch more cases.The text was updated successfully, but these errors were encountered: