Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
3cf8580f
Commit
3cf8580f
authored
Sep 08, 2021
by
Eduardo Bonet
Committed by
Natalia Tepluhina
Sep 08, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "Markers, ticks and labels in SVG images in Jupyter notebooks are not rendered"
parent
b9b54edc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
2 deletions
+13
-2
app/assets/javascripts/lib/dompurify.js
app/assets/javascripts/lib/dompurify.js
+1
-1
app/assets/javascripts/notebook/cells/output/html.vue
app/assets/javascripts/notebook/cells/output/html.vue
+4
-1
spec/frontend/lib/dompurify_spec.js
spec/frontend/lib/dompurify_spec.js
+8
-0
No files found.
app/assets/javascripts/lib/dompurify.js
View file @
3cf8580f
...
...
@@ -16,7 +16,7 @@ const getAllowedIconUrls = (gon = window.gon) =>
const
isUrlAllowed
=
(
url
)
=>
getAllowedIconUrls
().
some
((
allowedUrl
)
=>
url
.
startsWith
(
allowedUrl
));
const
isHrefSafe
=
(
url
)
=>
isUrlAllowed
(
url
)
||
isUrlAllowed
(
relativePathToAbsolute
(
url
,
getBaseURL
()));
isUrlAllowed
(
url
)
||
isUrlAllowed
(
relativePathToAbsolute
(
url
,
getBaseURL
()))
||
url
.
match
(
/^#/
)
;
const
removeUnsafeHref
=
(
node
,
attr
)
=>
{
if
(
!
node
.
hasAttribute
(
attr
))
{
...
...
app/assets/javascripts/notebook/cells/output/html.vue
View file @
3cf8580f
...
...
@@ -28,12 +28,15 @@ export default {
return
this
.
index
===
0
;
},
},
safeHtmlConfig
:
{
ADD_TAGS
:
[
'
use
'
],
// to support icon SVGs
},
};
</
script
>
<
template
>
<div
class=
"output"
>
<prompt
type=
"Out"
:count=
"count"
:show-output=
"showOutput"
/>
<div
v-safe-html=
"rawCode"
class=
"gl-overflow-auto"
></div>
<div
v-safe-html
:
[$
options.safeHtmlConfig]
=
"rawCode"
class=
"gl-overflow-auto"
></div>
</div>
</
template
>
spec/frontend/lib/dompurify_spec.js
View file @
3cf8580f
...
...
@@ -57,6 +57,14 @@ describe('~/lib/dompurify', () => {
});
});
it
(
"
doesn't sanitize local references
"
,
()
=>
{
const
htmlHref
=
`<svg><use href="#some-element"></use></svg>`
;
const
htmlXlink
=
`<svg><use xlink:href="#some-element"></use></svg>`
;
expect
(
sanitize
(
htmlHref
)).
toBe
(
htmlHref
);
expect
(
sanitize
(
htmlXlink
)).
toBe
(
htmlXlink
);
});
describe
.
each
`
type | gon
${
'
root
'
}
|
${
rootGon
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment