Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
renderjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
renderjs
Commits
b05c05f4
Commit
b05c05f4
authored
Nov 18, 2022
by
Romain Courteaud
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fail if DOMParser report HTML issue.
parent
846e9ef2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
3 deletions
+30
-3
renderjs.js
renderjs.js
+30
-3
No files found.
renderjs.js
View file @
b05c05f4
...
@@ -61,6 +61,32 @@
...
@@ -61,6 +61,32 @@
ScopeError
.
prototype
=
new
Error
();
ScopeError
.
prototype
=
new
Error
();
ScopeError
.
prototype
.
constructor
=
ScopeError
;
ScopeError
.
prototype
.
constructor
=
ScopeError
;
//////////////////////////////////////////
// ParserError
//////////////////////////////////////////
function
DOMParserError
(
message
)
{
this
.
name
=
"
DOMParserError
"
;
if
((
message
!==
undefined
)
&&
(
typeof
message
!==
"
string
"
))
{
throw
new
TypeError
(
'
You must pass a string for DOMParserError.
'
);
}
this
.
message
=
message
||
"
Default Message
"
;
}
DOMParserError
.
prototype
=
new
Error
();
DOMParserError
.
prototype
.
constructor
=
DOMParserError
;
//////////////////////////////////////////
// DOMParser
//////////////////////////////////////////
function
parseDocumentStringOrFail
(
string
,
mime_type
)
{
var
doc
=
new
DOMParser
().
parseFromString
(
string
,
mime_type
),
error_node
=
doc
.
querySelector
(
'
parsererror
'
);
if
(
error_node
!==
null
)
{
// parsing failed
throw
new
DOMParserError
(
error_node
.
textContent
);
}
return
doc
;
}
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// renderJS.IframeSerializationError
// renderJS.IframeSerializationError
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
...
@@ -1181,8 +1207,7 @@
...
@@ -1181,8 +1207,7 @@
.
push
(
function
handleDataURLAjaxResponse
(
xhr
)
{
.
push
(
function
handleDataURLAjaxResponse
(
xhr
)
{
// Insert a "base" element, in order to resolve all relative links
// Insert a "base" element, in order to resolve all relative links
// which could get broken with a data url
// which could get broken with a data url
var
doc
=
(
new
DOMParser
()).
parseFromString
(
xhr
.
responseText
,
var
doc
=
parseDocumentStringOrFail
(
xhr
.
responseText
,
'
text/html
'
),
'
text/html
'
),
base
=
doc
.
createElement
(
'
base
'
),
base
=
doc
.
createElement
(
'
base
'
),
blob
;
blob
;
base
.
href
=
url
;
base
.
href
=
url
;
...
@@ -1480,7 +1505,7 @@
...
@@ -1480,7 +1505,7 @@
// https://developer.mozilla.org/en-US/docs/Web/API/DOMParser
// https://developer.mozilla.org/en-US/docs/Web/API/DOMParser
// https://developer.mozilla.org/en-US/docs/Code_snippets/HTML_to_DOM
// https://developer.mozilla.org/en-US/docs/Code_snippets/HTML_to_DOM
tmp_constructor
.
__template_element
=
tmp_constructor
.
__template_element
=
(
new
DOMParser
()).
parseFromString
(
xhr
.
responseText
,
"
text/html
"
);
parseDocumentStringOrFail
(
xhr
.
responseText
,
"
text/html
"
);
parsed_html
=
renderJS
.
parseGadgetHTMLDocument
(
parsed_html
=
renderJS
.
parseGadgetHTMLDocument
(
tmp_constructor
.
__template_element
,
tmp_constructor
.
__template_element
,
url
,
url
,
...
@@ -1686,6 +1711,8 @@
...
@@ -1686,6 +1711,8 @@
renderJS
.
ScopeError
=
ScopeError
;
renderJS
.
ScopeError
=
ScopeError
;
renderJS
.
IframeSerializationError
=
IframeSerializationError
;
renderJS
.
IframeSerializationError
=
IframeSerializationError
;
renderJS
.
loopEventListener
=
loopEventListener
;
renderJS
.
loopEventListener
=
loopEventListener
;
renderJS
.
DOMParserError
=
DOMParserError
;
renderJS
.
parseDocumentStringOrFail
=
parseDocumentStringOrFail
;
window
.
rJS
=
window
.
renderJS
=
renderJS
;
window
.
rJS
=
window
.
renderJS
=
renderJS
;
window
.
__RenderJSGadget
=
RenderJSGadget
;
window
.
__RenderJSGadget
=
RenderJSGadget
;
window
.
__RenderJSEmbeddedGadget
=
RenderJSEmbeddedGadget
;
window
.
__RenderJSEmbeddedGadget
=
RenderJSEmbeddedGadget
;
...
...
Romain Courteaud
@romain
mentioned in merge request
erp5!1977 (merged)
·
Jul 31, 2024
mentioned in merge request
erp5!1977 (merged)
mentioned in merge request erp5!1977
Toggle commit list
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