Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
Hive Renderer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
Hive Renderer
Commits
690c13d4
Verified
Commit
690c13d4
authored
8 months ago
by
Bartłomiej Górnicki
Browse files
Options
Downloads
Patches
Plain Diff
fix: child node replacement
Closes #21
parent
dbaf2269
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!16
fix: child node replacement
Pipeline
#98314
failed
8 months ago
Stage: test
Changes
3
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
package-lock.json
+2423
-2300
2423 additions, 2300 deletions
package-lock.json
package.json
+21
-21
21 additions, 21 deletions
package.json
src/renderers/default/embedder/HtmlDOMParser.ts
+20
-5
20 additions, 5 deletions
src/renderers/default/embedder/HtmlDOMParser.ts
with
2464 additions
and
2326 deletions
package-lock.json
+
2423
−
2300
View file @
690c13d4
This diff is collapsed.
Click to expand it.
package.json
+
21
−
21
View file @
690c13d4
...
...
@@ -28,40 +28,40 @@
"hooks:install"
:
"husky"
},
"dependencies"
:
{
"
@xmldom/xmldom
"
:
"
0.8.1
"
,
"
@xmldom/xmldom
"
:
"
0.8.1
0
"
,
"
ow
"
:
"
0.28.2
"
,
"
remarkable
"
:
"
2.0.1
"
,
"
sanitize-html
"
:
"
2.1
2.1
"
,
"
sanitize-html
"
:
"
2.1
3.0
"
,
"
typescript-chained-error
"
:
"
1.6.0
"
,
"
universe-log
"
:
"
5.2.0
"
},
"devDependencies"
:
{
"
@commitlint/cli
"
:
"
1
8.6.1
"
,
"
@commitlint/config-conventional
"
:
"
1
8.6
.2
"
,
"
@commitlint/cli
"
:
"
1
9.3.0
"
,
"
@commitlint/config-conventional
"
:
"
1
9.2
.2
"
,
"
@engrave/eslint-config-engrave
"
:
"
1.0.0
"
,
"
@semantic-release/gitlab
"
:
"
13.
0.3
"
,
"
@types/chai
"
:
"
4.3.1
1
"
,
"
@types/jsdom
"
:
"
21.1.
6
"
,
"
@types/lodash
"
:
"
4.1
4.202
"
,
"
@types/mocha
"
:
"
10.0.
6
"
,
"
@types/node
"
:
"
20.1
1.2
0
"
,
"
@semantic-release/gitlab
"
:
"
13.
2.0
"
,
"
@types/chai
"
:
"
4.3.1
6
"
,
"
@types/jsdom
"
:
"
21.1.
7
"
,
"
@types/lodash
"
:
"
4.1
7.6
"
,
"
@types/mocha
"
:
"
10.0.
7
"
,
"
@types/node
"
:
"
20.1
4.1
0
"
,
"
@types/remarkable
"
:
"
2.0.8
"
,
"
@types/sanitize-html
"
:
"
2.11.0
"
,
"
@types/uuid
"
:
"
9
.0.
8
"
,
"
@types/uuid
"
:
"
10
.0.
0
"
,
"
chai
"
:
"
4.4.1
"
,
"
eslint
"
:
"
8.5
6.0
"
,
"
eslint
"
:
"
9.
6.0
"
,
"
husky
"
:
"
9.0.11
"
,
"
jsdom
"
:
"
24.
0
.0
"
,
"
jsdom
"
:
"
24.
1
.0
"
,
"
lodash
"
:
"
4.17.21
"
,
"
mocha
"
:
"
10.
3
.0
"
,
"
nyc
"
:
"
1
5.1
.0
"
,
"
prettier
"
:
"
3.
2.5
"
,
"
semantic-release
"
:
"
2
3
.0.
2
"
,
"
testcafe
"
:
"
3.
5.0
"
,
"
mocha
"
:
"
10.
6
.0
"
,
"
nyc
"
:
"
1
7.0
.0
"
,
"
prettier
"
:
"
3.
3.2
"
,
"
semantic-release
"
:
"
2
4
.0.
0
"
,
"
testcafe
"
:
"
3.
6.2
"
,
"
ts-node
"
:
"
10.9.2
"
,
"
typescript
"
:
"
5.
3
.3
"
,
"
uuid
"
:
"
9
.0.
1
"
,
"
webpack
"
:
"
5.9
0.3
"
,
"
typescript
"
:
"
5.
5
.3
"
,
"
uuid
"
:
"
10
.0.
0
"
,
"
webpack
"
:
"
5.9
2.1
"
,
"
webpack-cli
"
:
"
5.1.4
"
,
"
webpack-visualizer-plugin2
"
:
"
1.1.0
"
},
...
...
This diff is collapsed.
Click to expand it.
src/renderers/default/embedder/HtmlDOMParser.ts
+
20
−
5
View file @
690c13d4
...
...
@@ -135,7 +135,11 @@ export class HtmlDOMParser {
phishyDiv
.
textContent
=
`
${
child
.
textContent
}
/
${
url
}
`
;
phishyDiv
.
setAttribute
(
'
title
'
,
this
.
localization
.
phishingWarning
);
phishyDiv
.
setAttribute
(
'
class
'
,
'
phishy
'
);
(
child
as
any
).
parentNode
.
replaceChild
(
phishyDiv
,
child
);
const
parent
=
child
.
parentNode
;
if
(
parent
)
{
parent
.
appendChild
(
phishyDiv
);
parent
.
removeChild
(
child
);
}
}
else
{
child
.
setAttribute
(
'
href
'
,
sanitizedLink
);
}
...
...
@@ -157,7 +161,12 @@ export class HtmlDOMParser {
return
;
}
const
html
=
this
.
xmlSerializer
.
serializeToString
(
child
);
(
child
as
any
).
parentNode
.
replaceChild
(
this
.
domParser
.
parseFromString
(
`<div class="videoWrapper">
${
html
}
</div>`
),
child
);
const
wrapper
=
this
.
domParser
.
parseFromString
(
`<div class="videoWrapper">
${
html
}
</div>`
);
const
parent
=
child
.
parentNode
;
if
(
parent
)
{
parent
.
appendChild
(
wrapper
);
parent
.
removeChild
(
child
);
}
}
// TODO this is youtube specific but should be executed for all iframes and embedders
...
...
@@ -209,7 +218,11 @@ export class HtmlDOMParser {
const
content
=
this
.
linkify
(
data
);
if
(
this
.
mutate
&&
content
!==
data
)
{
const
newChild
=
this
.
domParser
.
parseFromString
(
`<span>
${
content
}
</span>`
);
(
child
.
parentNode
as
any
).
replaceChild
(
newChild
,
child
);
const
parent
=
child
.
parentNode
;
if
(
parent
)
{
parent
.
appendChild
(
newChild
);
parent
.
removeChild
(
child
);
}
return
newChild
;
}
}
catch
(
error
)
{
...
...
@@ -290,8 +303,10 @@ export class HtmlDOMParser {
const
pre
=
doc
.
createElement
(
'
pre
'
);
pre
.
setAttribute
(
'
class
'
,
'
image-url-only
'
);
pre
.
appendChild
(
doc
.
createTextNode
(
image
.
getAttribute
(
'
src
'
)
||
''
));
if
(
image
.
parentNode
)
{
image
.
parentNode
.
replaceChild
(
pre
,
image
);
const
parent
=
image
.
parentNode
;
if
(
parent
)
{
parent
.
appendChild
(
pre
);
parent
.
removeChild
(
image
);
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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