diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2019-01-24 19:53:00 +0300 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2019-01-24 19:53:48 +0300 |
commit | 304a2529db8963b06e16ea9df101ce0c07de702a (patch) | |
tree | f3185b11c3445e02e2a5b2bffeed1e1bb4ce52c1 /spec | |
parent | 52a4c0cb3f3fca755b0d46b794558073629f3bf0 (diff) |
Merge branch '11-7-security-stored-xss-via-katex' into 'security-11-7'
[11.7] Resolve "[Security] Stored XSS via KaTeX"
See merge request gitlab/gitlabhq!2820
(cherry picked from commit 53d5ce14f5b08a9733b8041b768ace2d1ec04d47)
63d8d0de 11.7 backport of fix for XSS in KaTex Links
699d42e4 Merge branch 'security-11-7' of https://dev.gitlab.org/gitlab/gitlabhq into...
Diffstat (limited to 'spec')
-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 |