Skip to content
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
3 changes: 3 additions & 0 deletions modules/markup/sanitizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ func createDefaultPolicy() *bluemonday.Policy {
// Allow classes for task lists
policy.AllowAttrs("class").Matching(regexp.MustCompile(`task-list-item`)).OnElements("li")

// Allow classes for org mode list item status.
policy.AllowAttrs("class").Matching(regexp.MustCompile(`^(unchecked|checked|indeterminate)$`)).OnElements("li")

// Allow icons
policy.AllowAttrs("class").Matching(regexp.MustCompile(`^icon(\s+[\p{L}\p{N}_-]+)+$`)).OnElements("i")

Expand Down
5 changes: 5 additions & 0 deletions modules/markup/sanitizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ func Test_Sanitizer(t *testing.T) {
`<p style="bad-color: red">Hello World</p>`, `<p>Hello World</p>`,
`<code style="bad-color: red">Hello World</code>`, `<code>Hello World</code>`,

// Org mode status of list items.
`<li class="checked"></li>`, `<li class="checked"></li>`,
`<li class="unchecked"></li>`, `<li class="unchecked"></li>`,
`<li class="indeterminate"></li>`, `<li class="indeterminate"></li>`,

// URLs
`<a href="cbthunderlink://somebase64string)">my custom URL scheme</a>`, `<a href="cbthunderlink://somebase64string)" rel="nofollow">my custom URL scheme</a>`,
`<a href="matrix:roomid/psumPMeAfzgAeQpXMG:feneas.org?action=join">my custom URL scheme</a>`, `<a href="matrix:roomid/psumPMeAfzgAeQpXMG:feneas.org?action=join" rel="nofollow">my custom URL scheme</a>`,
Expand Down
23 changes: 23 additions & 0 deletions web_src/css/markup/content.css
Original file line number Diff line number Diff line change
Expand Up @@ -556,3 +556,26 @@
border-top-left-radius: 0 !important;
border-top-right-radius: 0 !important;
}

.file-view.markup.orgmode li.unchecked::before {
content: "[ ] ";
}

.file-view.markup.orgmode li.checked::before {
content: "[x] ";
}

.file-view.markup.orgmode li.indeterminate::before {
content: "[-] ";
}

/* This is only needed for <p> because they are literally acting as paragraphs,
* and thus having an ::before on the same line would force the paragraph to
* move to the next line. This can be avoided by an inline-block display that
* avoids that property while still having the other properties of the block
* display. */
.file-view.markup.orgmode li.unchecked > p,
.file-view.markup.orgmode li.checked > p,
.file-view.markup.orgmode li.indeterminate > p {
display: inline-block;
}