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:
akkana%netscape.com
2000-05-16 00:37:41 +00:00
parent 210e774dac
commit dec9c88f83
12 changed files with 120 additions and 6 deletions

View File

@@ -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();

View File

@@ -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

View File

@@ -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) {

View File

@@ -49,6 +49,8 @@ TEST_FILES = \
doctype.xif \
xifdtplain.out \
xifdthtml.out \
simplemail.html \
simplemail.out \
$(NULL)
LINCS= \

View 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>
&gt; neither should a greater then symbol. <br>
&nbsp; 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!).&nbsp; </body>

View 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!).

View File

@@ -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();

View File

@@ -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

View File

@@ -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) {

View File

@@ -49,6 +49,8 @@ TEST_FILES = \
doctype.xif \
xifdtplain.out \
xifdthtml.out \
simplemail.html \
simplemail.out \
$(NULL)
LINCS= \

View 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>
&gt; neither should a greater then symbol. <br>
&nbsp; 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!).&nbsp; </body>

View 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!).