diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2019-01-24 14:21:22 +0000 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2019-01-24 14:21:42 +0000 |
commit | 733eb0e297e30c556101308f0af800b6023c267f (patch) | |
tree | 4cb523943e39852ad2c92108ebb75765b2bc7639 /spec/features/markdown/math_spec.rb | |
parent | b10f55b9dd9e12d4cd67bc0ec945e22e7f4bc6ab (diff) | |
download | gitlab-ce-733eb0e297e30c556101308f0af800b6023c267f.tar.gz |
Merge branch '11-5-security-stored-xss-via-katex' into 'security-11-5'
[11.5] Resolve "[Security] Stored XSS via KaTeX"
See merge request gitlab/gitlabhq!2756
(cherry picked from commit a4f28a482db2ccbbc2eae5ecda4a24b9993f7dfd)
429cae1b 11.5 backport of fix for XSS in KaTex Links
46ca66ed Merge branch 'security-11-5' of https://dev.gitlab.org/gitlab/gitlabhq into...
Diffstat (limited to 'spec/features/markdown/math_spec.rb')
-rw-r--r-- | spec/features/markdown/math_spec.rb | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/spec/features/markdown/math_spec.rb b/spec/features/markdown/math_spec.rb index 6a23d6b78ab..53abb5e3722 100644 --- a/spec/features/markdown/math_spec.rb +++ b/spec/features/markdown/math_spec.rb @@ -1,6 +1,8 @@ require 'spec_helper' describe 'Math rendering', :js do + let!(:project) { create(:project, :public) } + it 'renders inline and display math correctly' do description = <<~MATH This math is inline $`a^2+b^2=c^2`$. @@ -11,12 +13,26 @@ describe 'Math rendering', :js do ``` MATH - project = create(:project, :public) issue = create(:issue, project: project, description: description) visit project_issue_path(project, issue) - expect(page).to have_selector('.katex .mord.mathit', text: 'b') - expect(page).to have_selector('.katex-display .mord.mathit', text: 'b') + expect(page).to have_selector('.katex .mord.mathdefault', text: 'b') + expect(page).to have_selector('.katex-display .mord.mathdefault', text: 'b') + end + + it 'only renders non XSS links' do + description = <<~MATH + This link is valid $`\\href{javascript:alert('xss');}{xss}`$. + + This link is valid $`\\href{https://gitlab.com}{Gitlab}`$. + MATH + + issue = create(:issue, project: project, description: description) + + visit project_issue_path(project, issue) + + expect(page).to have_selector('.katex-error', text: "\href{javascript:alert('xss');}{xss}") + expect(page).to have_selector('.katex-html a', text: 'Gitlab') end end |