mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-24 17:36:14 -04:00
Merge pull request #1514 from ether/dont-die-on-bad-html
dont die on bad html but only warn to api logger but dont tell client th...
This commit is contained in:
commit
7d47d91a08
3 changed files with 31 additions and 10 deletions
|
@ -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("");
|
||||
pad.appendRevision(theChangeset);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue