mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-21 06:52:46 +01:00
dont die on bad html but only warn to api logger but dont tell client that it failed cause html was bad
This commit is contained in:
parent
14dca92692
commit
086132de66
1 changed files with 8 additions and 2 deletions
|
@ -29,7 +29,6 @@ function setPadHTML(pad, html, callback)
|
||||||
// by several orders of magnitude.
|
// by several orders of magnitude.
|
||||||
pad.setText("");
|
pad.setText("");
|
||||||
var padText = pad.text();
|
var padText = pad.text();
|
||||||
|
|
||||||
// Parse the incoming HTML with jsdom
|
// Parse the incoming HTML with jsdom
|
||||||
var doc = jsdom(html.replace(/>\n+</g, '><'));
|
var doc = jsdom(html.replace(/>\n+</g, '><'));
|
||||||
apiLogger.debug('html:');
|
apiLogger.debug('html:');
|
||||||
|
@ -38,8 +37,15 @@ function setPadHTML(pad, html, callback)
|
||||||
// Convert a dom tree into a list of lines and attribute liens
|
// Convert a dom tree into a list of lines and attribute liens
|
||||||
// using the content collector object
|
// using the content collector object
|
||||||
var cc = contentcollector.makeContentCollector(true, null, pad.pool);
|
var cc = contentcollector.makeContentCollector(true, null, pad.pool);
|
||||||
|
try{ // we use a try here because if the HTML is bad it will blow up
|
||||||
cc.collectContent(doc.childNodes[0]);
|
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();
|
var result = cc.finish();
|
||||||
|
|
||||||
apiLogger.debug('Lines:');
|
apiLogger.debug('Lines:');
|
||||||
var i;
|
var i;
|
||||||
for (i = 0; i < result.lines.length; i += 1)
|
for (i = 0; i < result.lines.length; i += 1)
|
||||||
|
|
Loading…
Reference in a new issue