Changes

Jump to: navigation, search

User:Vlam6

21,272 bytes added, 20:19, 11 November 2007
no edit summary
[http://zenit.senecac.on.ca/wiki/index.php/FSOSS_Report_by_vlam6 My FSOSS Report]
== Lab ==
==== Thunderbird Fix ====
<pre>
? labpatch.txt
? objdir-tbird-debug
? security/nss/cmd/shlibsign/NONE
? security/nss/cmd/shlibsign/mangle/NONE
? security/nss/lib/ckfw/builtins/NONE
? security/nss/lib/ckfw/capi/NONE
? security/nss/lib/freebl/NONE
? security/nss/lib/nss/NONE
? security/nss/lib/smime/NONE
? security/nss/lib/softoken/NONE
? security/nss/lib/softoken/legacydb/NONE
? security/nss/lib/ssl/NONE
Index: netwerk/streamconv/converters/mozTXTToHTMLConv.cpp
===================================================================
RCS file: /cvsroot/mozilla/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp,v
retrieving revision 1.85
diff -u -8 -p -r1.85 mozTXTToHTMLConv.cpp
--- netwerk/streamconv/converters/mozTXTToHTMLConv.cpp 11 Mar 2007 00:17:00 -0000 1.85
+++ netwerk/streamconv/converters/mozTXTToHTMLConv.cpp 11 Nov 2007 23:37:50 -0000
@@ -1,42 +1,42 @@
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
- *
+ *
* The "License" shall be the Mozilla Public License Version 1.1, except
* Sections 6.2 and 11, but with the addition of the below defined Section 14.
* You may obtain a copy of the Mozilla Public License Version 1.1 at
* <http://www.mozilla.org/MPL/>. The contents of this file are subject to the
* License; you may not use this file except in compliance with the License.
- *
+ *
* Section 14: MISCELLANEOUS.
* This License represents the complete agreement concerning subject matter
* hereof. If any provision of this License is held to be unenforceable, such
* provision shall be reformed only to the extent necessary to make it
* enforceable. This License shall be governed by German law provisions. Any
* litigation relating to this License shall be subject to German jurisdiction.
- *
+ *
* Once Covered Code has been published under a particular version of the
* License, You may always continue to use it under the terms of that version.
+ The Initial Developer and no one else has the right to modify the terms
* applicable to Covered Code created under this License.
* (End of Section 14)
- *
+ *
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
- *
+ *
* The Original Code is the Mozilla Text to HTML converter code.
- *
+ *
* The Initial Developer of the Original Code is
* Ben Bucksch <http://www.bucksch.org>.
* Portions created by Ben Bucksch are Copyright
* (C) 1999, 2000 Ben Bucksch. All Rights Reserved.
- *
+ *
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
@@ -69,17 +69,17 @@ const PRFloat64 growthRate = 1.2;
// 0xA0's and a single ending space, so need to treat 0xA0's as spaces.
// 0xA0 is the Latin1/Unicode character for "non-breaking space (nbsp)"
// Also recognize the Japanese ideographic space 0x3000 as a space.
static inline PRBool IsSpace(const PRUnichar aChar)
{
return (nsCRT::IsAsciiSpace(aChar) || aChar == 0xA0 || aChar == 0x3000);
}
-// Escape Char will take ch, escape it and append the result to
+// Escape Char will take ch, escape it and append the result to
// aStringToAppendTo
void
mozTXTToHTMLConv::EscapeChar(const PRUnichar ch, nsString& aStringToAppendTo)
{
switch (ch)
{
case '<':
aStringToAppendTo.AppendLiteral("&lt;");
@@ -94,17 +94,17 @@ mozTXTToHTMLConv::EscapeChar(const PRUni
aStringToAppendTo += ch;
}
return;
}
// EscapeStr takes the passed in string and
// escapes it IN PLACE.
-void
+void
mozTXTToHTMLConv::EscapeStr(nsString& aInString)
{
// the replace substring routines
// don't seem to work if you have a character
// in the in string that is also in the replacement
// string! =(
//aInString.ReplaceSubstring("&", "&amp;");
//aInString.ReplaceSubstring("<", "&lt;");
@@ -129,17 +129,17 @@ mozTXTToHTMLConv::EscapeStr(nsString& aI
i += 5; // skip past the integers we just added
break;
default:
i++;
}
}
}
-void
+void
mozTXTToHTMLConv::UnescapeStr(const PRUnichar * aInString, PRInt32 aStartPos, PRInt32 aLength, nsString& aOutString)
{
const PRUnichar * subString = nsnull;
for (PRUint32 i = aStartPos; PRInt32(i) - aStartPos < aLength;)
{
PRInt32 remainingChars = i - aStartPos;
if (aInString[i] == '&')
{
@@ -169,44 +169,44 @@ mozTXTToHTMLConv::UnescapeStr(const PRUn
{
aOutString += aInString[i];
i++;
}
}
}
void
-mozTXTToHTMLConv::CompleteAbbreviatedURL(const PRUnichar * aInString, PRInt32 aInLength,
+mozTXTToHTMLConv::CompleteAbbreviatedURL(const PRUnichar * aInString, PRInt32 aInLength,
const PRUint32 pos, nsString& aOutString)
{
NS_ASSERTION(pos < aInLength, "bad args to CompleteAbbreviatedURL, see bug #190851");
if (pos >= aInLength)
return;
if (aInString[pos] == '@')
{
// only pre-pend a mailto url if the string contains a .domain in it..
//i.e. we want to linkify johndoe@foo.com but not "let's meet @8pm"
nsDependentString inString(aInString, aInLength);
- if (inString.FindChar('.', pos) != kNotFound) // if we have a '.' after the @ sign....
+ if (inString.FindChar('.', pos) != kNotFound && (inString.Find("..", 0) == kNotFound)) { // if we have a '.' after the @ sign.... and make sure there is no double '.' anywhere
{
aOutString.AssignLiteral("mailto:");
aOutString += aInString;
}
}
else if (aInString[pos] == '.')
{
if (ItMatchesDelimited(aInString, aInLength,
NS_LITERAL_STRING("www.").get(), 4, LT_IGNORE, LT_IGNORE))
{
aOutString.AssignLiteral("http://");
aOutString += aInString;
}
else if (ItMatchesDelimited(aInString,aInLength, NS_LITERAL_STRING("ftp.").get(), 4, LT_IGNORE, LT_IGNORE))
- {
+ {
aOutString.AssignLiteral("ftp://");
aOutString += aInString;
}
}
}
PRBool
mozTXTToHTMLConv::FindURLStart(const PRUnichar * aInString, PRInt32 aInLength,
@@ -360,17 +360,17 @@ mozTXTToHTMLConv::FindURLEnd(const PRUni
return PR_FALSE;
}
default:
return PR_FALSE;
} //switch
}
void
-mozTXTToHTMLConv::CalculateURLBoundaries(const PRUnichar * aInString, PRInt32 aInStringLength,
+mozTXTToHTMLConv::CalculateURLBoundaries(const PRUnichar * aInString, PRInt32 aInStringLength,
const PRUint32 pos, const PRUint32 whathasbeendone,
const modetype check, const PRUint32 start, const PRUint32 end,
nsString& txtURL, nsString& desc,
PRInt32& replaceBefore, PRInt32& replaceAfter)
{
PRUint32 descstart = start;
switch(check)
{
@@ -385,17 +385,17 @@ mozTXTToHTMLConv::CalculateURLBoundaries
descstart = start - 1;
desc.Append(&aInString[descstart], end - descstart + 2); // include brackets
replaceAfter = end - pos + 1;
} break;
case freetext:
case abbreviated:
{
descstart = start;
- desc.Append(&aInString[descstart], end - start + 1); // don't include brackets
+ desc.Append(&aInString[descstart], end - start + 1); // don't include brackets
replaceAfter = end - pos;
} break;
default: break;
} //switch
EscapeStr(desc);
txtURL.Append(&aInString[start], end - start + 1);
@@ -414,17 +414,17 @@ PRBool mozTXTToHTMLConv::ShouldLinkify(c
return PR_FALSE;
nsCAutoString scheme;
nsresult rv = mIOService->ExtractScheme(aURL, scheme);
if(NS_FAILED(rv))
return PR_FALSE;
// Get the handler for this scheme.
- nsCOMPtr<nsIProtocolHandler> handler;
+ nsCOMPtr<nsIProtocolHandler> handler;
rv = mIOService->GetProtocolHandler(scheme.get(), getter_AddRefs(handler));
if(NS_FAILED(rv))
return PR_FALSE;
// Is it an external protocol handler? If not, linkify it.
nsCOMPtr<nsIExternalProtocolHandler> externalHandler = do_QueryInterface(handler, &rv);
if (!externalHandler)
return PR_TRUE; // handler is built-in, linkify it!
@@ -440,17 +440,17 @@ mozTXTToHTMLConv::CheckURLAndCreateHTML(
const nsString& txtURL, const nsString& desc, const modetype mode,
nsString& outputHTML)
{
// Create *uri from txtURL
nsCOMPtr<nsIURI> uri;
nsresult rv = NS_OK;
if (!mIOService)
mIOService = do_GetService(kIOServiceCID, &rv);
-
+
if (NS_FAILED(rv) || !mIOService)
return PR_FALSE;
// See if the url should be linkified.
NS_ConvertUTF16toUTF8 utf8URL(txtURL);
if (!ShouldLinkify(utf8URL))
return PR_FALSE;
@@ -639,17 +639,17 @@ mozTXTToHTMLConv::ItMatchesDelimited(con
nsCaseInsensitiveStringComparator())
)
return PR_FALSE;
return PR_TRUE;
}
PRUint32
-mozTXTToHTMLConv::NumberOfMatches(const PRUnichar * aInString, PRInt32 aInStringLength,
+mozTXTToHTMLConv::NumberOfMatches(const PRUnichar * aInString, PRInt32 aInStringLength,
const PRUnichar* rep, PRInt32 aRepLen, LIMTYPE before, LIMTYPE after)
{
PRUint32 result = 0;
for (PRInt32 i = 0; i < aInStringLength; i++)
{
const PRUnichar * indexIntoString = &aInString[i];
if (ItMatchesDelimited(indexIntoString, aInStringLength - i, rep, aRepLen, before, after))
@@ -658,17 +658,17 @@ mozTXTToHTMLConv::NumberOfMatches(const
return result;
}
// NOTE: the converted html for the phrase is appended to aOutString
// tagHTML and attributeHTML are plain ASCII (literal strings, in fact)
PRBool
mozTXTToHTMLConv::StructPhraseHit(const PRUnichar * aInString, PRInt32 aInStringLength, PRBool col0,
- const PRUnichar* tagTXT, PRInt32 aTagTXTLen,
+ const PRUnichar* tagTXT, PRInt32 aTagTXTLen,
const char* tagHTML, const char* attributeHTML,
nsString& aOutString, PRUint32& openTags)
{
/* We're searching for the following pattern:
LT_DELIMITER - "*" - ALPHA -
[ some text (maybe more "*"-pairs) - ALPHA ] "*" - LT_DELIMITER.
<strong> is only inserted, if existance of a pair could be verified
We use the first opening/closing tag, if we can choose */
@@ -679,19 +679,19 @@ mozTXTToHTMLConv::StructPhraseHit(const
{
newOffset = &aInString[1];
newLength = aInStringLength - 1;
}
// opening tag
if
(
- ItMatchesDelimited(aInString, aInStringLength, tagTXT, aTagTXTLen,
+ ItMatchesDelimited(aInString, aInStringLength, tagTXT, aTagTXTLen,
(col0 ? LT_IGNORE : LT_DELIMITER), LT_ALPHA) // is opening tag
- && NumberOfMatches(newOffset, newLength, tagTXT, aTagTXTLen,
+ && NumberOfMatches(newOffset, newLength, tagTXT, aTagTXTLen,
LT_ALPHA, LT_DELIMITER) // remaining closing tags
> openTags
)
{
openTags++;
aOutString.AppendLiteral("<");
aOutString.AppendASCII(tagHTML);
aOutString.Append(PRUnichar(' '));
@@ -723,17 +723,17 @@ PRBool
mozTXTToHTMLConv::SmilyHit(const PRUnichar * aInString, PRInt32 aLength, PRBool col0,
const char* tagTXT, const char* imageName,
nsString& outputHTML, PRInt32& glyphTextLen)
{
if ( !aInString || !tagTXT || !imageName )
return PR_FALSE;
PRInt32 tagLen = nsCRT::strlen(tagTXT);
-
+
PRUint32 delim = (col0 ? 0 : 1) + tagLen;
if
(
(col0 || IsSpace(aInString[0]))
&&
(
aLength <= PRInt32(delim) ||
@@ -746,47 +746,47 @@ mozTXTToHTMLConv::SmilyHit(const PRUnich
aInString[delim] == ';' ||
aInString[delim] == '8' ||
aInString[delim] == '>' ||
aInString[delim] == '!' ||
aInString[delim] == '?'
)
&& IsSpace(aInString[delim + 1])
)
- && ItMatchesDelimited(aInString, aLength, NS_ConvertASCIItoUTF16(tagTXT).get(), tagLen,
+ && ItMatchesDelimited(aInString, aLength, NS_ConvertASCIItoUTF16(tagTXT).get(), tagLen,
col0 ? LT_IGNORE : LT_DELIMITER, LT_IGNORE)
// Note: tests at different pos for LT_IGNORE and LT_DELIMITER
)
{
if (!col0)
{
outputHTML.Truncate();
outputHTML.Append(PRUnichar(' '));
}
outputHTML.AppendLiteral("<span class=\""); // <span class="
AppendASCIItoUTF16(imageName, outputHTML); // e.g. smiley-frown
- outputHTML.AppendLiteral("\" title=\""); // " title="
+ outputHTML.AppendLiteral("\" title=\""); // " title="
AppendASCIItoUTF16(tagTXT, outputHTML); // smiley tooltip
- outputHTML.AppendLiteral("\"><span>"); // "><span>
- AppendASCIItoUTF16(tagTXT, outputHTML); // original text
+ outputHTML.AppendLiteral("\"><span>"); // "><span>
+ AppendASCIItoUTF16(tagTXT, outputHTML); // original text
outputHTML.AppendLiteral("</span></span>"); // </span></span>
glyphTextLen = (col0 ? 0 : 1) + tagLen;
return PR_TRUE;
}
return PR_FALSE;
}
// the glyph is appended to aOutputString instead of the original string...
PRBool
mozTXTToHTMLConv::GlyphHit(const PRUnichar * aInString, PRInt32 aInLength, PRBool col0,
nsString& aOutputString, PRInt32& glyphTextLen)
{
- PRUnichar text0 = aInString[0];
+ PRUnichar text0 = aInString[0];
PRUnichar text1 = aInString[1];
PRUnichar firstChar = (col0 ? text0 : text1);
// temporary variable used to store the glyph html text
nsAutoString outputHTML;
PRBool bTestSmilie;
PRBool bArg;
int i;
@@ -813,116 +813,116 @@ mozTXTToHTMLConv::GlyphHit(const PRUnich
bTestSmilie = PR_TRUE;
bArg = PR_FALSE;
}
if ( bTestSmilie && (
SmilyHit(aInString, aInLength, bArg,
":-)",
"moz-smiley-s1", // smile
outputHTML, glyphTextLen) ||
-
+
SmilyHit(aInString, aInLength, bArg,
":)",
"moz-smiley-s1", // smile
outputHTML, glyphTextLen) ||
-
+
SmilyHit(aInString, aInLength, bArg,
":-D",
"moz-smiley-s5", // laughing
outputHTML, glyphTextLen) ||
-
+
SmilyHit(aInString, aInLength, bArg,
":-(",
"moz-smiley-s2", // frown
outputHTML, glyphTextLen) ||
-
+
SmilyHit(aInString, aInLength, bArg,
":(",
"moz-smiley-s2", // frown
outputHTML, glyphTextLen) ||
-
+
SmilyHit(aInString, aInLength, bArg,
":-[",
"moz-smiley-s6", // embarassed
outputHTML, glyphTextLen) ||
-
+
SmilyHit(aInString, aInLength, bArg,
";-)",
"moz-smiley-s3", // wink
outputHTML, glyphTextLen) ||
SmilyHit(aInString, aInLength, col0,
";)",
"moz-smiley-s3", // wink
outputHTML, glyphTextLen) ||
-
+
SmilyHit(aInString, aInLength, bArg,
":-\\",
"moz-smiley-s7", // undecided
outputHTML, glyphTextLen) ||
-
+
SmilyHit(aInString, aInLength, bArg,
":-P",
"moz-smiley-s4", // tongue
outputHTML, glyphTextLen) ||
-
+
SmilyHit(aInString, aInLength, bArg,
";-P",
"moz-smiley-s4", // tongue
- outputHTML, glyphTextLen) ||
-
+ outputHTML, glyphTextLen) ||
+
SmilyHit(aInString, aInLength, bArg,
"=-O",
"moz-smiley-s8", // surprise
outputHTML, glyphTextLen) ||
-
+
SmilyHit(aInString, aInLength, bArg,
":-*",
"moz-smiley-s9", // kiss
outputHTML, glyphTextLen) ||
-
+
SmilyHit(aInString, aInLength, bArg,
">:o",
"moz-smiley-s10", // yell
outputHTML, glyphTextLen) ||
-
+
SmilyHit(aInString, aInLength, bArg,
">:-o",
"moz-smiley-s10", // yell
outputHTML, glyphTextLen) ||
-
+
SmilyHit(aInString, aInLength, bArg,
"8-)",
"moz-smiley-s11", // cool
outputHTML, glyphTextLen) ||
-
+
SmilyHit(aInString, aInLength, bArg,
":-$",
"moz-smiley-s12", // money
outputHTML, glyphTextLen) ||
-
+
SmilyHit(aInString, aInLength, bArg,
":-!",
"moz-smiley-s13", // foot
outputHTML, glyphTextLen) ||
-
+
SmilyHit(aInString, aInLength, bArg,
"O:-)",
"moz-smiley-s14", // innocent
outputHTML, glyphTextLen) ||
-
+
SmilyHit(aInString, aInLength, bArg,
":'(",
"moz-smiley-s15", // cry
outputHTML, glyphTextLen) ||
-
+
SmilyHit(aInString, aInLength, bArg,
":-X",
"moz-smiley-s16", // sealed
- outputHTML, glyphTextLen)
+ outputHTML, glyphTextLen)
)
)
{
aOutputString.Append(outputHTML);
return PR_TRUE;
}
i++;
}
@@ -949,37 +949,37 @@ mozTXTToHTMLConv::GlyphHit(const PRUnich
aOutputString.AppendLiteral("&plusmn;");
glyphTextLen = 3;
return PR_TRUE;
}
}
// x^2 => x<sup>2</sup>, also handle powers x^-2, x^0.5
// implement regular expression /[\dA-Za-z\)\]}]\^-?\d+(\.\d+)*[^\dA-Za-z]/
- if
+ if
(
text1 == '^'
- &&
+ &&
(
- nsCRT::IsAsciiDigit(text0) || nsCRT::IsAsciiAlpha(text0) ||
+ nsCRT::IsAsciiDigit(text0) || nsCRT::IsAsciiAlpha(text0) ||
text0 == ')' || text0 == ']' || text0 == '}'
)
&&
(
2 < aInLength && nsCRT::IsAsciiDigit(aInString[2]) ||
3 < aInLength && aInString[2] == '-' && nsCRT::IsAsciiDigit(aInString[3])
)
)
{
// Find first non-digit
PRInt32 delimPos = 3; // skip "^" and first digit (or '-')
for (; delimPos < aInLength
&&
(
- nsCRT::IsAsciiDigit(aInString[delimPos]) ||
+ nsCRT::IsAsciiDigit(aInString[delimPos]) ||
aInString[delimPos] == '.' && delimPos + 1 < aInLength &&
nsCRT::IsAsciiDigit(aInString[delimPos + 1])
);
delimPos++)
;
if (delimPos < aInLength && nsCRT::IsAsciiAlpha(aInString[delimPos]))
{
@@ -1016,17 +1016,17 @@ mozTXTToHTMLConv::GlyphHit(const PRUnich
/***************************************************************************
Library-internal Interface
****************************************************************************/
mozTXTToHTMLConv::mozTXTToHTMLConv()
{
}
-mozTXTToHTMLConv::~mozTXTToHTMLConv()
+mozTXTToHTMLConv::~mozTXTToHTMLConv()
{
}
NS_IMPL_ISUPPORTS1(mozTXTToHTMLConv, mozITXTToHTMLConv)
PRInt32
mozTXTToHTMLConv::CiteLevelTXT(const PRUnichar *line,
PRUint32& logLineStart)
@@ -1214,17 +1214,17 @@ mozTXTToHTMLConv::ScanTXT(const PRUnicha
i++;
break;
}
}
}
void
mozTXTToHTMLConv::ScanHTML(nsString& aInString, PRUint32 whattodo, nsString &aOutString)
-{
+{
// some common variables we were recalculating
// every time inside the for loop...
PRInt32 lengthOfInString = aInString.Length();
const PRUnichar * uniBuffer = aInString.get();
#ifdef DEBUG_BenB_Perf
PRTime parsing_start = PR_IntervalNow();
#endif
@@ -1269,18 +1269,18 @@ mozTXTToHTMLConv::ScanHTML(nsString& aIn
aOutString.Append(&uniBuffer[start], PRUint32(i) - start);
}
else
{
PRUint32 start = PRUint32(i);
i = aInString.FindChar('<', i);
if (i == kNotFound)
i = lengthOfInString;
-
- nsString tempString;
+
+ nsString tempString;
tempString.SetCapacity(PRUint32((PRUint32(i) - start) * growthRate));
UnescapeStr(uniBuffer, start, PRUint32(i) - start, tempString);
ScanTXT(tempString.get(), tempString.Length(), whattodo, aOutString);
}
}
#ifdef DEBUG_BenB_Perf
printf("ScanHTML time: %d ms\n", PR_IntervalToMilliseconds(PR_IntervalNow() - parsing_start));
</pre>
== IRC Commands ==
* /join #channel <join chann>
1
edit

Navigation menu