-
-
Notifications
You must be signed in to change notification settings - Fork 3k
dont die on bad html but only warn to api logger but dont tell client th... #1514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
086132d
dont die on bad html but only warn to api logger but dont tell client…
JohnMcLear e152c47
include the callback call, for sanity and stop the pad from being nuk…
JohnMcLear 9e1dfc9
docs for setHTML
JohnMcLear 198110e
drunk comments
JohnMcLear 7c03bc2
when exporting HTML include html and body
JohnMcLear 58bbfd8
resolve merge conflict
JohnMcLear 7dd2945
Remove duplicate doc entry for setHTML()
lebrinkma dd8af99
Add input validation for html param in setHTML()
lebrinkma 3d8edef
Merge pull request #2035 from lebrinkma/dont-die-on-bad-html
JohnMcLear File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,11 +25,6 @@ function setPadHTML(pad, html, callback) | |
| { | ||
| var apiLogger = log4js.getLogger("ImportHtml"); | ||
|
|
||
| // Clean the pad. This makes the rest of the code easier | ||
| // by several orders of magnitude. | ||
| pad.setText(""); | ||
| var padText = pad.text(); | ||
|
|
||
| // Parse the incoming HTML with jsdom | ||
| try{ | ||
| var doc = jsdom(html.replace(/>\n+</g, '><')); | ||
|
|
@@ -44,8 +39,15 @@ function setPadHTML(pad, html, callback) | |
| // Convert a dom tree into a list of lines and attribute liens | ||
| // using the content collector object | ||
| var cc = contentcollector.makeContentCollector(true, null, pad.pool); | ||
| cc.collectContent(doc.childNodes[0]); | ||
| try{ // we use a try here because if the HTML is bad it will blow up | ||
| cc.collectContent(doc.childNodes[0]); | ||
| }catch(e){ | ||
| apiLogger.warn("HTML was not properly formed", e); | ||
| return; // We don't process the HTML because it was bad.. | ||
| } | ||
|
|
||
| var result = cc.finish(); | ||
|
|
||
| apiLogger.debug('Lines:'); | ||
| var i; | ||
| for (i = 0; i < result.lines.length; i += 1) | ||
|
|
@@ -90,6 +92,7 @@ function setPadHTML(pad, html, callback) | |
| // the changeset is ready! | ||
| var theChangeset = builder.toString(); | ||
| apiLogger.debug('The changeset: ' + theChangeset); | ||
| pad.setText(""); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You set it to nothing before writing to it. |
||
| pad.appendRevision(theChangeset); | ||
| } | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just returning here will result in a timeout on the other end, i think. You could add
callback(new customError("Malformed html","apierror"));