From 7d08825730ff77d044c7791446ed213b4da163bd Mon Sep 17 00:00:00 2001 From: "scc%mozilla.org" Date: Sun, 11 Jun 2000 09:14:09 +0000 Subject: [PATCH] don't try to extract characters from an empty string --- .../html/document/src/nsHTMLContentSink.cpp | 24 ++++++++++--------- .../html/document/src/nsHTMLContentSink.cpp | 24 ++++++++++--------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/content/html/document/src/nsHTMLContentSink.cpp b/content/html/document/src/nsHTMLContentSink.cpp index 0169c4510e1..ac24a00c8e1 100644 --- a/content/html/document/src/nsHTMLContentSink.cpp +++ b/content/html/document/src/nsHTMLContentSink.cpp @@ -611,20 +611,22 @@ HTMLContentSink::GetAttributeValueAt(const nsIParserNode& aNode, aResult.Append(value); aResult.Trim("\b\r\t\n",PR_TRUE,PR_TRUE,PR_TRUE); - // Strip quotes if present - PRUnichar first = aResult.First(); - if ((first == '\"') || (first == '\'')) { - if (aResult.Last() == first) { - aResult.Cut(0, 1); - PRInt32 pos = aResult.Length() - 1; - if (pos >= 0) { - aResult.Cut(pos, 1); + if ( !aResult.IsEmpty() ) { + // Strip quotes if present + PRUnichar first = aResult.First(); + if ((first == '\"') || (first == '\'')) { + if (aResult.Last() == first) { + aResult.Cut(0, 1); + PRInt32 pos = aResult.Length() - 1; + if (pos >= 0) { + aResult.Cut(pos, 1); + } + } else { + // Mismatched quotes - leave them in } - } else { - // Mismatched quotes - leave them in } + ReduceEntities(aResult); } - ReduceEntities(aResult); } nsresult diff --git a/layout/html/document/src/nsHTMLContentSink.cpp b/layout/html/document/src/nsHTMLContentSink.cpp index 0169c4510e1..ac24a00c8e1 100644 --- a/layout/html/document/src/nsHTMLContentSink.cpp +++ b/layout/html/document/src/nsHTMLContentSink.cpp @@ -611,20 +611,22 @@ HTMLContentSink::GetAttributeValueAt(const nsIParserNode& aNode, aResult.Append(value); aResult.Trim("\b\r\t\n",PR_TRUE,PR_TRUE,PR_TRUE); - // Strip quotes if present - PRUnichar first = aResult.First(); - if ((first == '\"') || (first == '\'')) { - if (aResult.Last() == first) { - aResult.Cut(0, 1); - PRInt32 pos = aResult.Length() - 1; - if (pos >= 0) { - aResult.Cut(pos, 1); + if ( !aResult.IsEmpty() ) { + // Strip quotes if present + PRUnichar first = aResult.First(); + if ((first == '\"') || (first == '\'')) { + if (aResult.Last() == first) { + aResult.Cut(0, 1); + PRInt32 pos = aResult.Length() - 1; + if (pos >= 0) { + aResult.Cut(pos, 1); + } + } else { + // Mismatched quotes - leave them in } - } else { - // Mismatched quotes - leave them in } + ReduceEntities(aResult); } - ReduceEntities(aResult); } nsresult