From 212b1c5362c44f2b1aa42ec3fc2dd4b135d5324d Mon Sep 17 00:00:00 2001 From: "neil@parkwaycc.co.uk" Date: Mon, 7 May 2007 04:09:54 -0700 Subject: [PATCH] Bug 379339 StringBegins/EndsWith inconsistent with nsReadableUtils.cpp r=bsmedberg sr=darin --- xpcom/glue/nsStringAPI.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/xpcom/glue/nsStringAPI.h b/xpcom/glue/nsStringAPI.h index 81d005d9602..0431eb3f11e 100644 --- a/xpcom/glue/nsStringAPI.h +++ b/xpcom/glue/nsStringAPI.h @@ -1228,32 +1228,32 @@ inline PRBool StringBeginsWith(const nsAString& aSource, const nsAString& aSubstring, nsAString::ComparatorFunc aComparator = nsAString::DefaultComparator) { - return StringHead(aSource, aSubstring.Length()). - Equals(aSubstring, aComparator); + return aSubstring.Length() <= aSource.Length() && + StringHead(aSource, aSubstring.Length()).Equals(aSubstring, aComparator); } inline PRBool StringEndsWith(const nsAString& aSource, const nsAString& aSubstring, nsAString::ComparatorFunc aComparator = nsAString::DefaultComparator) { - return StringTail(aSource, aSubstring.Length()). - Equals(aSubstring, aComparator); + return aSubstring.Length() <= aSource.Length() && + StringTail(aSource, aSubstring.Length()).Equals(aSubstring, aComparator); } inline PRBool StringBeginsWith(const nsACString& aSource, const nsACString& aSubstring, nsACString::ComparatorFunc aComparator = nsACString::DefaultComparator) { - return StringHead(aSource, aSubstring.Length()). - Equals(aSubstring, aComparator); + return aSubstring.Length() <= aSource.Length() && + StringHead(aSource, aSubstring.Length()).Equals(aSubstring, aComparator); } inline PRBool StringEndsWith(const nsACString& aSource, const nsACString& aSubstring, nsACString::ComparatorFunc aComparator = nsACString::DefaultComparator) { - return StringTail(aSource, aSubstring.Length()). - Equals(aSubstring, aComparator); + return aSubstring.Length() <= aSource.Length() && + StringTail(aSource, aSubstring.Length()).Equals(aSubstring, aComparator); } /**