{"action":"created","comment":{"url":"https://api.github.com/repos/go-gitea/gitea/pulls/comments/348285649","pull_request_review_id":319499702,"id":348285649,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDM0ODI4NTY0OQ==","diff_hunk":"@@ -25,42 +28,113 @@ type MarkupParser struct {\n \tIsInputFile    bool\n }\n \n+// MarkupSanitizer defines the policy for whitelisting attributes on\n+// certain elements.\n+type MarkupSanitizer struct {\n+\tElements   []string\n+\tAllowAttrs []string\n+\tRegexps    []*regexp.Regexp\n+}\n+\n func newMarkup() {\n-\textensionReg := regexp.MustCompile(`\\.\\w`)\n \tfor _, sec := range Cfg.Section(\"markup\").ChildSections() {\n \t\tname := strings.TrimPrefix(sec.Name(), \"markup.\")\n \t\tif name == \"\" {\n \t\t\tlog.Warn(\"name is empty, markup \" + sec.Name() + \"ignored\")\n \t\t\tcontinue\n \t\t}\n \n-\t\textensions := sec.Key(\"FILE_EXTENSIONS\").Strings(\",\")\n-\t\tvar exts = make([]string, 0, len(extensions))\n-\t\tfor _, extension := range extensions {\n-\t\t\tif !extensionReg.MatchString(extension) {\n-\t\t\t\tlog.Warn(sec.Name() + \" file extension \" + extension + \" is invalid. Extension ignored\")\n-\t\t\t} else {\n-\t\t\t\texts = append(exts, extension)\n-\t\t\t}\n+\t\tif name == \"sanitizer\" {\n+\t\t\tnewMarkupSanitizer(name, sec)\n+\t\t} else {\n+\t\t\tnewMarkupRenderer(name, sec)\n \t\t}\n+\t}\n+}\n+\n+func newMarkupSanitizer(name string, sec *ini.Section) {\n+\t// Implementation detail: go-ini/ini doesn't currently support\n+\t// ini arrays properly: https://github.com/go-ini/ini/issues/197","path":"modules/setting/markup.go","position":55,"original_position":55,"commit_id":"b2308331f2d77b2ab5aeafe60d10be0c1a91b85c","original_commit_id":"b2308331f2d77b2ab5aeafe60d10be0c1a91b85c","user":{"login":"guillep2k","id":18600385,"node_id":"MDQ6VXNlcjE4NjAwMzg1","avatar_url":"https://avatars1.githubusercontent.com/u/18600385?v=4","gravatar_id":"","url":"https://api.github.com/users/guillep2k","html_url":"https://github.com/guillep2k","followers_url":"https://api.github.com/users/guillep2k/followers","following_url":"https://api.github.com/users/guillep2k/following{/other_user}","gists_url":"https://api.github.com/users/guillep2k/gists{/gist_id}","starred_url":"https://api.github.com/users/guillep2k/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guillep2k/subscriptions","organizations_url":"https://api.github.com/users/guillep2k/orgs","repos_url":"https://api.github.com/users/guillep2k/repos","events_url":"https://api.github.com/users/guillep2k/events{/privacy}","received_events_url":"https://api.github.com/users/guillep2k/received_events","type":"User","site_admin":false},"body":"This comment is confusing because it actually doed support them as \"shadows\" and you're using them below.","created_at":"2019-11-20T04:22:00Z","updated_at":"2019-11-20T04:28:56Z","html_url":"https://github.com/go-gitea/gitea/pull/9075#discussion_r348285649","pull_request_url":"https://api.github.com/repos/go-gitea/gitea/pulls/9075","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/go-gitea/gitea/pulls/comments/348285649"},"html":{"href":"https://github.com/go-gitea/gitea/pull/9075#discussion_r348285649"},"pull_request":{"href":"https://api.github.com/repos/go-gitea/gitea/pulls/9075"}}},"pull_request":{"url":"https://api.github.com/repos/go-gitea/gitea/pulls/9075","id":342789632,"node_id":"MDExOlB1bGxSZXF1ZXN0MzQyNzg5NjMy","html_url":"https://github.com/go-gitea/gitea/pull/9075","diff_url":"https://github.com/go-gitea/gitea/pull/9075.diff","patch_url":"https://github.com/go-gitea/gitea/pull/9075.patch","issue_url":"https://api.github.com/repos/go-gitea/gitea/issues/9075","number":9075,"state":"open","locked":false,"title":"Markdown: Sanitizier Configuration","user":{"login":"cipherboy","id":914030,"node_id":"MDQ6VXNlcjkxNDAzMA==","avatar_url":"https://avatars2.githubusercontent.com/u/914030?v=4","gravatar_id":"","url":"https://api.github.com/users/cipherboy","html_url":"https://github.com/cipherboy","followers_url":"https://api.github.com/users/cipherboy/followers","following_url":"https://api.github.com/users/cipherboy/following{/other_user}","gists_url":"https://api.github.com/users/cipherboy/gists{/gist_id}","starred_url":"https://api.github.com/users/cipherboy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cipherboy/subscriptions","organizations_url":"https://api.github.com/users/cipherboy/orgs","repos_url":"https://api.github.com/users/cipherboy/repos","events_url":"https://api.github.com/users/cipherboy/events{/privacy}","received_events_url":"https://api.github.com/users/cipherboy/received_events","type":"User","site_admin":false},"body":"Allowing the gitea administrator to configure sanitization policy allows\r\nthem to couple external renders and custom templates to support more\r\nmarkup. In particular, the `pandoc` renderer allows generating KaTeX\r\nannotations, wrapping them in `<span>` elements with class `math` and\r\neither `inline` or `display` (depending on whether or not inline or\r\nblock mode was requested).\r\n    \r\nThis iteration gives the administrator whitelisting powers; carefully\r\ncrafted regexes will thus let through only the desired attributes\r\nnecessary to support their custom markup.\r\n\r\nResolves: #9054\r\n\r\n---\r\n\r\n - [x] I have read the contributing guidelines.\r\n - [x] I have used the DCO sign-off.\r\n - [x] I have [attempted to run](https://github.com/go-gitea/gitea/issues/9054#issuecomment-555564884) unit tests\r\n      - This failed for me on `=== TestXSSUserFullName (integrations/xss_test.go:17)`, but `master` branch also failed for the same test case.\r\n - [x] I ran `make golangci-lint` (since `make lint` seemed to suggest `make revive` was deprecated):\r\n        ```bash\r\n        $ make golangci-lint\r\n        golangci-lint run --timeout 5m\r\n        WARN [runner] Can't run linter unused: buildssa: analysis skipped: errors in package: [-: code in directory /home/cipherboy/GitHub/cipherboy/gitea expects import \"code.gitea.io/gitea\"] \r\n        WARN [runner] Can't run linter goanalysis_metalinter: assign: failed prerequisites: inspect@_/home/cipherboy/GitHub/cipherboy/gitea \r\n        $ \r\n        ```\r\n\r\n---\r\n\r\nI'm currently running this on `git.cipherboy.com` and it works for my use case. \r\n\r\nWould you want a test case for this? I'm not familiar with your test setup, so I'd appreciate an example for how I should test this if so. \r\n\r\n![Screenshot from 2019-11-19 12-04-13](https://user-images.githubusercontent.com/914030/69168459-b84ad080-0ac4-11ea-9a85-f573b23a6c9b.png)\r\n","created_at":"2019-11-19T17:05:01Z","updated_at":"2019-11-20T04:28:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b390a5fac9657b07b384d1aea19a5cb35b1c5d9a","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":475283583,"node_id":"MDU6TGFiZWw0NzUyODM1ODM=","url":"https://api.github.com/repos/go-gitea/gitea/labels/lgtm/need%202","name":"lgtm/need 2","color":"d93f0b","default":false,"description":null}],"milestone":null,"commits_url":"https://api.github.com/repos/go-gitea/gitea/pulls/9075/commits","review_comments_url":"https://api.github.com/repos/go-gitea/gitea/pulls/9075/comments","review_comment_url":"https://api.github.com/repos/go-gitea/gitea/pulls/comments{/number}","comments_url":"https://api.github.com/repos/go-gitea/gitea/issues/9075/comments","statuses_url":"https://api.github.com/repos/go-gitea/gitea/statuses/b2308331f2d77b2ab5aeafe60d10be0c1a91b85c","head":{"label":"cipherboy:markdown-sanitizer-config","ref":"markdown-sanitizer-config","sha":"b2308331f2d77b2ab5aeafe60d10be0c1a91b85c","user":{"login":"cipherboy","id":914030,"node_id":"MDQ6VXNlcjkxNDAzMA==","avatar_url":"https://avatars2.githubusercontent.com/u/914030?v=4","gravatar_id":"","url":"https://api.github.com/users/cipherboy","html_url":"https://github.com/cipherboy","followers_url":"https://api.github.com/users/cipherboy/followers","following_url":"https://api.github.com/users/cipherboy/following{/other_user}","gists_url":"https://api.github.com/users/cipherboy/gists{/gist_id}","starred_url":"https://api.github.com/users/cipherboy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cipherboy/subscriptions","organizations_url":"https://api.github.com/users/cipherboy/orgs","repos_url":"https://api.github.com/users/cipherboy/repos","events_url":"https://api.github.com/users/cipherboy/events{/privacy}","received_events_url":"https://api.github.com/users/cipherboy/received_events","type":"User","site_admin":false},"repo":{"id":222690654,"node_id":"MDEwOlJlcG9zaXRvcnkyMjI2OTA2NTQ=","name":"gitea","full_name":"cipherboy/gitea","private":false,"owner":{"login":"cipherboy","id":914030,"node_id":"MDQ6VXNlcjkxNDAzMA==","avatar_url":"https://avatars2.githubusercontent.com/u/914030?v=4","gravatar_id":"","url":"https://api.github.com/users/cipherboy","html_url":"https://github.com/cipherboy","followers_url":"https://api.github.com/users/cipherboy/followers","following_url":"https://api.github.com/users/cipherboy/following{/other_user}","gists_url":"https://api.github.com/users/cipherboy/gists{/gist_id}","starred_url":"https://api.github.com/users/cipherboy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cipherboy/subscriptions","organizations_url":"https://api.github.com/users/cipherboy/orgs","repos_url":"https://api.github.com/users/cipherboy/repos","events_url":"https://api.github.com/users/cipherboy/events{/privacy}","received_events_url":"https://api.github.com/users/cipherboy/received_events","type":"User","site_admin":false},"html_url":"https://github.com/cipherboy/gitea","description":"Git with a cup of tea, painless self-hosted git service","fork":true,"url":"https://api.github.com/repos/cipherboy/gitea","forks_url":"https://api.github.com/repos/cipherboy/gitea/forks","keys_url":"https://api.github.com/repos/cipherboy/gitea/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cipherboy/gitea/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cipherboy/gitea/teams","hooks_url":"https://api.github.com/repos/cipherboy/gitea/hooks","issue_events_url":"https://api.github.com/repos/cipherboy/gitea/issues/events{/number}","events_url":"https://api.github.com/repos/cipherboy/gitea/events","assignees_url":"https://api.github.com/repos/cipherboy/gitea/assignees{/user}","branches_url":"https://api.github.com/repos/cipherboy/gitea/branches{/branch}","tags_url":"https://api.github.com/repos/cipherboy/gitea/tags","blobs_url":"https://api.github.com/repos/cipherboy/gitea/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cipherboy/gitea/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cipherboy/gitea/git/refs{/sha}","trees_url":"https://api.github.com/repos/cipherboy/gitea/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cipherboy/gitea/statuses/{sha}","languages_url":"https://api.github.com/repos/cipherboy/gitea/languages","stargazers_url":"https://api.github.com/repos/cipherboy/gitea/stargazers","contributors_url":"https://api.github.com/repos/cipherboy/gitea/contributors","subscribers_url":"https://api.github.com/repos/cipherboy/gitea/subscribers","subscription_url":"https://api.github.com/repos/cipherboy/gitea/subscription","commits_url":"https://api.github.com/repos/cipherboy/gitea/commits{/sha}","git_commits_url":"https://api.github.com/repos/cipherboy/gitea/git/commits{/sha}","comments_url":"https://api.github.com/repos/cipherboy/gitea/comments{/number}","issue_comment_url":"https://api.github.com/repos/cipherboy/gitea/issues/comments{/number}","contents_url":"https://api.github.com/repos/cipherboy/gitea/contents/{+path}","compare_url":"https://api.github.com/repos/cipherboy/gitea/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cipherboy/gitea/merges","archive_url":"https://api.github.com/repos/cipherboy/gitea/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cipherboy/gitea/downloads","issues_url":"https://api.github.com/repos/cipherboy/gitea/issues{/number}","pulls_url":"https://api.github.com/repos/cipherboy/gitea/pulls{/number}","milestones_url":"https://api.github.com/repos/cipherboy/gitea/milestones{/number}","notifications_url":"https://api.github.com/repos/cipherboy/gitea/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cipherboy/gitea/labels{/name}","releases_url":"https://api.github.com/repos/cipherboy/gitea/releases{/id}","deployments_url":"https://api.github.com/repos/cipherboy/gitea/deployments","created_at":"2019-11-19T12:26:54Z","updated_at":"2019-11-20T03:07:00Z","pushed_at":"2019-11-20T03:22:47Z","git_url":"git://github.com/cipherboy/gitea.git","ssh_url":"git@github.com:cipherboy/gitea.git","clone_url":"https://github.com/cipherboy/gitea.git","svn_url":"https://github.com/cipherboy/gitea","homepage":"https://gitea.io","size":147515,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"go-gitea:master","ref":"master","sha":"108bed202349532d22f55c51a794ad48ae662e17","user":{"login":"go-gitea","id":12724356,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEyNzI0MzU2","avatar_url":"https://avatars1.githubusercontent.com/u/12724356?v=4","gravatar_id":"","url":"https://api.github.com/users/go-gitea","html_url":"https://github.com/go-gitea","followers_url":"https://api.github.com/users/go-gitea/followers","following_url":"https://api.github.com/users/go-gitea/following{/other_user}","gists_url":"https://api.github.com/users/go-gitea/gists{/gist_id}","starred_url":"https://api.github.com/users/go-gitea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/go-gitea/subscriptions","organizations_url":"https://api.github.com/users/go-gitea/orgs","repos_url":"https://api.github.com/users/go-gitea/repos","events_url":"https://api.github.com/users/go-gitea/events{/privacy}","received_events_url":"https://api.github.com/users/go-gitea/received_events","type":"Organization","site_admin":false},"repo":{"id":72495579,"node_id":"MDEwOlJlcG9zaXRvcnk3MjQ5NTU3OQ==","name":"gitea","full_name":"go-gitea/gitea","private":false,"owner":{"login":"go-gitea","id":12724356,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEyNzI0MzU2","avatar_url":"https://avatars1.githubusercontent.com/u/12724356?v=4","gravatar_id":"","url":"https://api.github.com/users/go-gitea","html_url":"https://github.com/go-gitea","followers_url":"https://api.github.com/users/go-gitea/followers","following_url":"https://api.github.com/users/go-gitea/following{/other_user}","gists_url":"https://api.github.com/users/go-gitea/gists{/gist_id}","starred_url":"https://api.github.com/users/go-gitea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/go-gitea/subscriptions","organizations_url":"https://api.github.com/users/go-gitea/orgs","repos_url":"https://api.github.com/users/go-gitea/repos","events_url":"https://api.github.com/users/go-gitea/events{/privacy}","received_events_url":"https://api.github.com/users/go-gitea/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/go-gitea/gitea","description":"Git with a cup of tea, painless self-hosted git service","fork":false,"url":"https://api.github.com/repos/go-gitea/gitea","forks_url":"https://api.github.com/repos/go-gitea/gitea/forks","keys_url":"https://api.github.com/repos/go-gitea/gitea/keys{/key_id}","collaborators_url":"https://api.github.com/repos/go-gitea/gitea/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/go-gitea/gitea/teams","hooks_url":"https://api.github.com/repos/go-gitea/gitea/hooks","issue_events_url":"https://api.github.com/repos/go-gitea/gitea/issues/events{/number}","events_url":"https://api.github.com/repos/go-gitea/gitea/events","assignees_url":"https://api.github.com/repos/go-gitea/gitea/assignees{/user}","branches_url":"https://api.github.com/repos/go-gitea/gitea/branches{/branch}","tags_url":"https://api.github.com/repos/go-gitea/gitea/tags","blobs_url":"https://api.github.com/repos/go-gitea/gitea/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/go-gitea/gitea/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/go-gitea/gitea/git/refs{/sha}","trees_url":"https://api.github.com/repos/go-gitea/gitea/git/trees{/sha}","statuses_url":"https://api.github.com/repos/go-gitea/gitea/statuses/{sha}","languages_url":"https://api.github.com/repos/go-gitea/gitea/languages","stargazers_url":"https://api.github.com/repos/go-gitea/gitea/stargazers","contributors_url":"https://api.github.com/repos/go-gitea/gitea/contributors","subscribers_url":"https://api.github.com/repos/go-gitea/gitea/subscribers","subscription_url":"https://api.github.com/repos/go-gitea/gitea/subscription","commits_url":"https://api.github.com/repos/go-gitea/gitea/commits{/sha}","git_commits_url":"https://api.github.com/repos/go-gitea/gitea/git/commits{/sha}","comments_url":"https://api.github.com/repos/go-gitea/gitea/comments{/number}","issue_comment_url":"https://api.github.com/repos/go-gitea/gitea/issues/comments{/number}","contents_url":"https://api.github.com/repos/go-gitea/gitea/contents/{+path}","compare_url":"https://api.github.com/repos/go-gitea/gitea/compare/{base}...{head}","merges_url":"https://api.github.com/repos/go-gitea/gitea/merges","archive_url":"https://api.github.com/repos/go-gitea/gitea/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/go-gitea/gitea/downloads","issues_url":"https://api.github.com/repos/go-gitea/gitea/issues{/number}","pulls_url":"https://api.github.com/repos/go-gitea/gitea/pulls{/number}","milestones_url":"https://api.github.com/repos/go-gitea/gitea/milestones{/number}","notifications_url":"https://api.github.com/repos/go-gitea/gitea/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/go-gitea/gitea/labels{/name}","releases_url":"https://api.github.com/repos/go-gitea/gitea/releases{/id}","deployments_url":"https://api.github.com/repos/go-gitea/gitea/deployments","created_at":"2016-11-01T02:13:26Z","updated_at":"2019-11-20T03:46:56Z","pushed_at":"2019-11-20T04:26:28Z","git_url":"git://github.com/go-gitea/gitea.git","ssh_url":"git@github.com:go-gitea/gitea.git","clone_url":"https://github.com/go-gitea/gitea.git","svn_url":"https://github.com/go-gitea/gitea","homepage":"https://gitea.io","size":147507,"stargazers_count":17054,"watchers_count":17054,"language":"Go","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1927,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":1234,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":1927,"open_issues":1234,"watchers":17054,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/go-gitea/gitea/pulls/9075"},"html":{"href":"https://github.com/go-gitea/gitea/pull/9075"},"issue":{"href":"https://api.github.com/repos/go-gitea/gitea/issues/9075"},"comments":{"href":"https://api.github.com/repos/go-gitea/gitea/issues/9075/comments"},"review_comments":{"href":"https://api.github.com/repos/go-gitea/gitea/pulls/9075/comments"},"review_comment":{"href":"https://api.github.com/repos/go-gitea/gitea/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/go-gitea/gitea/pulls/9075/commits"},"statuses":{"href":"https://api.github.com/repos/go-gitea/gitea/statuses/b2308331f2d77b2ab5aeafe60d10be0c1a91b85c"}},"author_association":"NONE"}}
{"actor":{"display_login":"guillep2k"}}