You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow render HTML with css/js external links (#19017)
* Allow render HTML with css/js external links
* Fix bug because of filename escape chars
* Fix lint
* Update docs about new configuration item
* Fix bug of render HTML in sub directory
* Add CSP head for displaying iframe in rendering file
* Fix test
* Apply suggestions from code review
Co-authored-by: delvh <[email protected]>
* Some improvements
* some improvement
* revert change in SanitizerDisabled of external renderer
* Add sandbox for iframe and support allow-scripts and allow-same-origin
* refactor
* fix
* fix lint
* fine tune
* use single option RENDER_CONTENT_MODE, use sandbox=allow-scripts
* fine tune CSP
* Apply suggestions from code review
Co-authored-by: wxiaoguang <[email protected]>
Co-authored-by: delvh <[email protected]>
Co-authored-by: wxiaoguang <[email protected]>
Copy file name to clipboardExpand all lines: custom/conf/app.example.ini
+5-2
Original file line number
Diff line number
Diff line change
@@ -2181,8 +2181,11 @@ PATH =
2181
2181
;RENDER_COMMAND = "asciidoc --out-file=- -"
2182
2182
;; Don't pass the file on STDIN, pass the filename as argument instead.
2183
2183
;IS_INPUT_FILE = false
2184
-
; Don't filter html tags and attributes if true
2185
-
;DISABLE_SANITIZER = false
2184
+
;; How the content will be rendered.
2185
+
;; * sanitized: Sanitize the content and render it inside current page, default to only allow a few HTML tags and attributes. Customized sanitizer rules can be defined in [markup.sanitizer.*] .
2186
+
;; * no-sanitizer: Disable the sanitizer and render the content inside current page. It's **insecure** and may lead to XSS attack if the content contains malicious code.
2187
+
;; * iframe: Render the content in a separate standalone page and embed it into current page by iframe. The iframe is in sandbox mode with same-origin disabled, and the JS code are safely isolated from parent page.
Copy file name to clipboardExpand all lines: docs/content/doc/advanced/config-cheat-sheet.en-us.md
+5-2
Original file line number
Diff line number
Diff line change
@@ -1026,13 +1026,16 @@ IS_INPUT_FILE = false
1026
1026
command. Multiple extensions needs a comma as splitter.
1027
1027
- RENDER\_COMMAND: External command to render all matching extensions.
1028
1028
- IS\_INPUT\_FILE: **false** Input is not a standard input but a file param followed `RENDER_COMMAND`.
1029
-
- DISABLE_SANITIZER: **false** Don't filter html tags and attributes if true. Don't change this to true except you know what that means.
1029
+
- RENDER_CONTENT_MODE: **sanitized** How the content will be rendered.
1030
+
- sanitized: Sanitize the content and render it inside current page, default to only allow a few HTML tags and attributes. Customized sanitizer rules can be defined in `[markup.sanitizer.*]`.
1031
+
- no-sanitizer: Disable the sanitizer and render the content inside current page. It's **insecure** and may lead to XSS attack if the content contains malicious code.
1032
+
- iframe: Render the content in a separate standalone page and embed it into current page by iframe. The iframe is in sandbox mode with same-origin disabled, and the JS code are safely isolated from parent page.
1030
1033
1031
1034
Two special environment variables are passed to the render command:
1032
1035
-`GITEA_PREFIX_SRC`, which contains the current URL prefix in the `src` path tree. To be used as prefix for links.
1033
1036
-`GITEA_PREFIX_RAW`, which contains the current URL prefix in the `raw` path tree. To be used as prefix for image paths.
1034
1037
1035
-
If `DISABLE_SANITIZER` is false, Gitea supports customizing the sanitization policy for rendered HTML. The example below will support KaTeX output from pandoc.
1038
+
If `RENDER_CONTENT_MODE` is `sanitized`, Gitea supports customizing the sanitization policy for rendered HTML. The example below will support KaTeX output from pandoc.
0 commit comments