35118: Fix from Daniel Bratell <bratell@lysator.liu.se> to fix signature delimiters in format=flowed
git-svn-id: svn://10.0.0.236/trunk@69929 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -1132,10 +1132,19 @@ nsHTMLToTXTSinkStream::EndLine(PRBool softlinebreak)
|
||||
}
|
||||
if(mCurrentLine.Length()>0)
|
||||
mEmptyLines=-1;
|
||||
|
||||
// Output current line
|
||||
// Remove SPACE from the end of the line.
|
||||
while(' ' == mCurrentLine[mCurrentLine.Length()-1])
|
||||
// Remove SPACE from the end of the line, unless we got
|
||||
// "-- " in a format=flowed output. "-- " is the sig delimiter
|
||||
// by convention and shouldn't be touched even in format=flowed
|
||||
// (see RFC 2646).
|
||||
nsAutoString sig_delimiter;
|
||||
sig_delimiter.AssignWithConversion("-- ");
|
||||
while((' ' == mCurrentLine[mCurrentLine.Length()-1]) &&
|
||||
((sig_delimiter != mCurrentLine) ||
|
||||
!(mFlags & nsIDocumentEncoder::OutputFormatFlowed)))
|
||||
mCurrentLine.SetLength(mCurrentLine.Length()-1);
|
||||
|
||||
mCurrentLine.AppendWithConversion(NS_LINEBREAK);
|
||||
WriteSimple(mCurrentLine);
|
||||
mCurrentLine.Truncate();
|
||||
|
||||
@@ -57,12 +57,13 @@ TEST_FILES = \
|
||||
doctype.xif \
|
||||
xifdtplain.out \
|
||||
xifdthtml.out \
|
||||
simplemail.html \
|
||||
simplemail.out \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
install::
|
||||
$(INSTALL) -m 555 $(srcdir)/TestOutSinks $(DIST)/bin
|
||||
$(INSTALL) -m 555 $(srcdir)/TestOutSinks.pl $(DIST)/bin
|
||||
$(INSTALL) $(addprefix $(srcdir)/, $(TEST_FILES)) $(DIST)/bin/OutTestData
|
||||
|
||||
|
||||
@@ -70,6 +70,13 @@ if ($status != 0) {
|
||||
$errmsg = "$errmsg mailquote.out";
|
||||
}
|
||||
|
||||
print "Testing format=flowed output ...\n";
|
||||
$status = system("TestOutput -i text/html -o text/plain -f 66 -w 50 -c OutTestData/simplemail.out OutTestData/simplemail.html");
|
||||
if ($status != 0) {
|
||||
print "Format=flowed test failed.\n";
|
||||
$errmsg = "$errmsg simplemail.out";
|
||||
}
|
||||
|
||||
print "Testing conversion of XIF entities ...\n";
|
||||
$status = system("TestOutput -i text/xif -o text/plain -c OutTestData/entityxif.out OutTestData/entityxif.xif");
|
||||
if ($status != 0) {
|
||||
|
||||
@@ -49,6 +49,8 @@ TEST_FILES = \
|
||||
doctype.xif \
|
||||
xifdtplain.out \
|
||||
xifdthtml.out \
|
||||
simplemail.html \
|
||||
simplemail.out \
|
||||
$(NULL)
|
||||
|
||||
LINCS= \
|
||||
|
||||
18
mozilla/htmlparser/tests/outsinks/simplemail.html
Normal file
18
mozilla/htmlparser/tests/outsinks/simplemail.html
Normal file
@@ -0,0 +1,18 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
<body>This is a mail
|
||||
with a couple of long lines and then a sig. This is used as test of the
|
||||
format=flowed output in the nsHTMLToTXTSinkstream. If this test fails and
|
||||
none else, it's likely the spaces at the ends of the lines that are missing.
|
||||
They aren't easily seen without looking at the data in an editor and checking
|
||||
where the end of line is.<br>
|
||||
<br>
|
||||
Testing Space stuffing<br>
|
||||
From shouldn't start a line.<br>
|
||||
> neither should a greater then symbol. <br>
|
||||
Nor a space.<br>
|
||||
--<br>
|
||||
Above is NOT a sig delimiter since it's missing the trailing SPACE:<br>
|
||||
<br>
|
||||
-- <br>
|
||||
Above is a sig delimiter. I hope.<br>
|
||||
A sig (wow!). </body>
|
||||
20
mozilla/htmlparser/tests/outsinks/simplemail.out
Normal file
20
mozilla/htmlparser/tests/outsinks/simplemail.out
Normal file
@@ -0,0 +1,20 @@
|
||||
This is a mail with a couple of long lines and
|
||||
then a sig. This is used as test of the format=
|
||||
flowed output in the nsHTMLToTXTSinkstream. If
|
||||
this test fails and none else, it's likely the
|
||||
spaces at the ends of the lines that are missing.
|
||||
They aren't easily seen without looking at the
|
||||
data in an editor and checking where the end of
|
||||
line is.
|
||||
|
||||
Testing Space stuffing
|
||||
From shouldn't start a line.
|
||||
> neither should a greater then symbol.
|
||||
Nor a space.
|
||||
--
|
||||
Above is NOT a sig delimiter since it's missing
|
||||
the trailing SPACE:
|
||||
|
||||
--
|
||||
Above is a sig delimiter. I hope.
|
||||
A sig (wow!).
|
||||
@@ -1132,10 +1132,19 @@ nsHTMLToTXTSinkStream::EndLine(PRBool softlinebreak)
|
||||
}
|
||||
if(mCurrentLine.Length()>0)
|
||||
mEmptyLines=-1;
|
||||
|
||||
// Output current line
|
||||
// Remove SPACE from the end of the line.
|
||||
while(' ' == mCurrentLine[mCurrentLine.Length()-1])
|
||||
// Remove SPACE from the end of the line, unless we got
|
||||
// "-- " in a format=flowed output. "-- " is the sig delimiter
|
||||
// by convention and shouldn't be touched even in format=flowed
|
||||
// (see RFC 2646).
|
||||
nsAutoString sig_delimiter;
|
||||
sig_delimiter.AssignWithConversion("-- ");
|
||||
while((' ' == mCurrentLine[mCurrentLine.Length()-1]) &&
|
||||
((sig_delimiter != mCurrentLine) ||
|
||||
!(mFlags & nsIDocumentEncoder::OutputFormatFlowed)))
|
||||
mCurrentLine.SetLength(mCurrentLine.Length()-1);
|
||||
|
||||
mCurrentLine.AppendWithConversion(NS_LINEBREAK);
|
||||
WriteSimple(mCurrentLine);
|
||||
mCurrentLine.Truncate();
|
||||
|
||||
@@ -57,12 +57,13 @@ TEST_FILES = \
|
||||
doctype.xif \
|
||||
xifdtplain.out \
|
||||
xifdthtml.out \
|
||||
simplemail.html \
|
||||
simplemail.out \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
install::
|
||||
$(INSTALL) -m 555 $(srcdir)/TestOutSinks $(DIST)/bin
|
||||
$(INSTALL) -m 555 $(srcdir)/TestOutSinks.pl $(DIST)/bin
|
||||
$(INSTALL) $(addprefix $(srcdir)/, $(TEST_FILES)) $(DIST)/bin/OutTestData
|
||||
|
||||
|
||||
@@ -70,6 +70,13 @@ if ($status != 0) {
|
||||
$errmsg = "$errmsg mailquote.out";
|
||||
}
|
||||
|
||||
print "Testing format=flowed output ...\n";
|
||||
$status = system("TestOutput -i text/html -o text/plain -f 66 -w 50 -c OutTestData/simplemail.out OutTestData/simplemail.html");
|
||||
if ($status != 0) {
|
||||
print "Format=flowed test failed.\n";
|
||||
$errmsg = "$errmsg simplemail.out";
|
||||
}
|
||||
|
||||
print "Testing conversion of XIF entities ...\n";
|
||||
$status = system("TestOutput -i text/xif -o text/plain -c OutTestData/entityxif.out OutTestData/entityxif.xif");
|
||||
if ($status != 0) {
|
||||
|
||||
@@ -49,6 +49,8 @@ TEST_FILES = \
|
||||
doctype.xif \
|
||||
xifdtplain.out \
|
||||
xifdthtml.out \
|
||||
simplemail.html \
|
||||
simplemail.out \
|
||||
$(NULL)
|
||||
|
||||
LINCS= \
|
||||
|
||||
18
mozilla/parser/htmlparser/tests/outsinks/simplemail.html
Normal file
18
mozilla/parser/htmlparser/tests/outsinks/simplemail.html
Normal file
@@ -0,0 +1,18 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
<body>This is a mail
|
||||
with a couple of long lines and then a sig. This is used as test of the
|
||||
format=flowed output in the nsHTMLToTXTSinkstream. If this test fails and
|
||||
none else, it's likely the spaces at the ends of the lines that are missing.
|
||||
They aren't easily seen without looking at the data in an editor and checking
|
||||
where the end of line is.<br>
|
||||
<br>
|
||||
Testing Space stuffing<br>
|
||||
From shouldn't start a line.<br>
|
||||
> neither should a greater then symbol. <br>
|
||||
Nor a space.<br>
|
||||
--<br>
|
||||
Above is NOT a sig delimiter since it's missing the trailing SPACE:<br>
|
||||
<br>
|
||||
-- <br>
|
||||
Above is a sig delimiter. I hope.<br>
|
||||
A sig (wow!). </body>
|
||||
20
mozilla/parser/htmlparser/tests/outsinks/simplemail.out
Normal file
20
mozilla/parser/htmlparser/tests/outsinks/simplemail.out
Normal file
@@ -0,0 +1,20 @@
|
||||
This is a mail with a couple of long lines and
|
||||
then a sig. This is used as test of the format=
|
||||
flowed output in the nsHTMLToTXTSinkstream. If
|
||||
this test fails and none else, it's likely the
|
||||
spaces at the ends of the lines that are missing.
|
||||
They aren't easily seen without looking at the
|
||||
data in an editor and checking where the end of
|
||||
line is.
|
||||
|
||||
Testing Space stuffing
|
||||
From shouldn't start a line.
|
||||
> neither should a greater then symbol.
|
||||
Nor a space.
|
||||
--
|
||||
Above is NOT a sig delimiter since it's missing
|
||||
the trailing SPACE:
|
||||
|
||||
--
|
||||
Above is a sig delimiter. I hope.
|
||||
A sig (wow!).
|
||||
Reference in New Issue
Block a user