Fixed a bug that creates invalid HTML at Export that lets Abiwords parser crash
parent
2cc7dcb751
commit
90ba811bb5
|
@ -119,8 +119,10 @@ function getHTMLFromAtext(pad, atext)
|
|||
var taker = Changeset.stringIterator(text);
|
||||
var assem = Changeset.stringAssembler();
|
||||
|
||||
var openTags = [];
|
||||
function emitOpenTag(i)
|
||||
{
|
||||
openTags.unshift(i);
|
||||
assem.append('<');
|
||||
assem.append(tags[i]);
|
||||
assem.append('>');
|
||||
|
@ -128,11 +130,28 @@ function getHTMLFromAtext(pad, atext)
|
|||
|
||||
function emitCloseTag(i)
|
||||
{
|
||||
openTags.shift();
|
||||
assem.append('</');
|
||||
assem.append(tags[i]);
|
||||
assem.append('>');
|
||||
}
|
||||
|
||||
function orderdCloseTags(tags2close)
|
||||
{
|
||||
for(var i=0;i<openTags.length;i++)
|
||||
{
|
||||
for(var j=0;j<tags2close.length;j++)
|
||||
{
|
||||
if(tags2close[j] == openTags[i])
|
||||
{
|
||||
emitCloseTag(tags2close[j]);
|
||||
i--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var urls = _findURLs(text);
|
||||
|
||||
var idx = 0;
|
||||
|
@ -204,18 +223,25 @@ function getHTMLFromAtext(pad, atext)
|
|||
}
|
||||
}
|
||||
|
||||
var tags2close = [];
|
||||
|
||||
for (var i = propVals.length - 1; i >= 0; i--)
|
||||
{
|
||||
if (propVals[i] === LEAVE)
|
||||
{
|
||||
emitCloseTag(i);
|
||||
//emitCloseTag(i);
|
||||
tags2close.push(i);
|
||||
propVals[i] = false;
|
||||
}
|
||||
else if (propVals[i] === STAY)
|
||||
{
|
||||
emitCloseTag(i);
|
||||
//emitCloseTag(i);
|
||||
tags2close.push(i);
|
||||
}
|
||||
}
|
||||
|
||||
orderdCloseTags(tags2close);
|
||||
|
||||
for (var i = 0; i < propVals.length; i++)
|
||||
{
|
||||
if (propVals[i] === ENTER || propVals[i] === STAY)
|
||||
|
@ -235,14 +261,18 @@ function getHTMLFromAtext(pad, atext)
|
|||
|
||||
assem.append(_escapeHTML(s));
|
||||
} // end iteration over spans in line
|
||||
|
||||
var tags2close = [];
|
||||
for (var i = propVals.length - 1; i >= 0; i--)
|
||||
{
|
||||
if (propVals[i])
|
||||
{
|
||||
emitCloseTag(i);
|
||||
tags2close.push(i);
|
||||
propVals[i] = false;
|
||||
}
|
||||
}
|
||||
|
||||
orderdCloseTags(tags2close);
|
||||
} // end processNextChars
|
||||
if (urls)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue