Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
dd6e7fd7
Unverified
Commit
dd6e7fd7
authored
4 years ago
by
Dillon Dumesnil
Browse files
Options
Downloads
Patches
Plain Diff
Exclude script and style tags content
Also removing the exclusion of link since links never have content
parent
57347755
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
common/static/common/js/utils/clamp-html.js
+1
-1
1 addition, 1 deletion
common/static/common/js/utils/clamp-html.js
common/static/common/js/utils/clamp-html.test.jsx
+4
-4
4 additions, 4 deletions
common/static/common/js/utils/clamp-html.test.jsx
with
5 additions
and
5 deletions
common/static/common/js/utils/clamp-html.js
+
1
−
1
View file @
dd6e7fd7
...
...
@@ -12,7 +12,7 @@
function
clampHtmlByWords
(
root
,
wordsLeft
)
{
'
use strict
'
;
if
(
root
.
nodeName
===
'
SCRIPT
'
||
root
.
nodeName
===
'
LINK
'
)
{
if
(
root
.
nodeName
===
'
SCRIPT
'
||
root
.
nodeName
===
'
STYLE
'
)
{
return
wordsLeft
;
// early exit and ignore
}
...
...
This diff is collapsed.
Click to expand it.
common/static/common/js/utils/clamp-html.test.jsx
+
4
−
4
View file @
dd6e7fd7
...
...
@@ -3,8 +3,8 @@ import ReactDOM from 'react-dom';
import
{
clampHtmlByWords
}
from
'
./clamp-html
'
;
let
container
;
const
scriptTag
=
'
<script src="/asset-v1:edX+testX+1T2021+type@asset+block/script.js"></script>
'
;
const
style
sheet
=
'
<link rel="stylesheet" type="text/css" href="/asset-v1:edX+testX+1T2021+type@asset+block/introjs.css"
>
'
;
const
scriptTag
=
'
<script src="/asset-v1:edX+testX+1T2021+type@asset+block/script.js">
const ignore = "me here"; alert("BAD");
</script>
'
;
const
style
Tag
=
'
<style>h1 {color: orange;}</style
>
'
;
beforeEach
(()
=>
{
container
=
document
.
createElement
(
"
div
"
);
...
...
@@ -28,8 +28,8 @@ describe('ClampHtml', () => {
[
'
a <i>aa <em>aaa</em> ab</i>
'
,
3
,
'
a <i>aa <em>aaa…</em></i>
'
],
[
'
a <i>aa ab</i> b c
'
,
4
,
'
a <i>aa ab</i> b…
'
],
[
scriptTag
+
'
a b c
'
,
2
,
scriptTag
+
'
a b…
'
],
[
style
sheet
+
'
a b c
'
,
2
,
style
sheet
+
'
a b…
'
],
[
scriptTag
+
style
sheet
+
'
a b c
'
,
2
,
scriptTag
+
style
sheet
+
'
a b…
'
],
[
style
Tag
+
'
a b c
'
,
2
,
style
Tag
+
'
a b…
'
],
[
scriptTag
+
style
Tag
+
'
a b c
'
,
2
,
scriptTag
+
style
Tag
+
'
a b…
'
],
])(
'
clamps by words: %s, %i
'
,
(
input
,
wordsLeft
,
expected
)
=>
{
const
div
=
ReactDOM
.
render
(<
div
dangerouslySetInnerHTML
=
{
{
__html
:
input
}
}
/>,
container
);
clampHtmlByWords
(
div
,
wordsLeft
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment