Fis for 2818 part 1 - crash in CleanHtmlL RCL_3
authorSebastian Brannstrom <sebastianb@symbian.org>
Fri, 12 Nov 2010 17:27:16 +0100
branchRCL_3
changeset 333 c80c7fb835c2
parent 332 88a24b8b97d8
child 334 a7cb97979427
Fis for 2818 part 1 - crash in CleanHtmlL
engine/src/PodcastUtils.cpp
--- a/engine/src/PodcastUtils.cpp	Fri Nov 12 17:26:03 2010 +0100
+++ b/engine/src/PodcastUtils.cpp	Fri Nov 12 17:27:16 2010 +0100
@@ -68,13 +68,13 @@
 
 EXPORT_C void PodcastUtils::CleanHtmlL(TDes &str)
 {
-
+	DP("PodcastUtils::CleanHtmlL BEGIN");
 	if (str.Length() == 0)
 		{
 		return;
 		}
-	
 // miscellaneous cleanup
+	DP("    miscellaneous cleanup");
 	const TChar KLineBreak(CEditableText::ELineBreak); 
 	_LIT(KNewLine, "\n");
 	_LIT(KNewLineWindows, "\r\n");
@@ -82,7 +82,7 @@
 	ReplaceString(str, KNewLineWindows, KNullDesC);
 
 // strip out HTML tags
-	
+	DP("    strip out HTML tags");
 	TInt startPos = str.Locate('<');
 	TInt endPos = str.Locate('>');
 	HBufC* tmpBuf = HBufC::NewLC(KMaxDescriptionLength);
@@ -115,6 +115,7 @@
 	}
 		
 // change HTML encoded chars to unicode
+	DP("    change HTML encoded chars to unicode");
 	startPos = str.Locate('&');
 	endPos = str.Locate(';');
 	while (startPos != KErrNotFound && endPos != KErrNotFound && endPos > startPos)
@@ -207,18 +208,20 @@
 	if(str.Length()>1)
 		{
 		// chop away newlines at start
-		while ((str[0] == KLineBreak) )  {
+		DP("    chop away newlines at start");
+		while (str.Length() > 0 && (str[0] == KLineBreak))  {
 			str = str.Mid(1);
 		}
 		
 		// chop away newlines at end
-	
-		while ((str[str.Length()-1] == KLineBreak)) {
+		DP("    chop away newlines at end");
+		while (str.Length() > 0 && (str[str.Length()-1] == KLineBreak)) {
 			str = str.Left(str.Length()-1);
 		}
 
 		str.Trim();
 		}
+	DP("PodcastUtils::CleanHtmlL END");
 }
 
 EXPORT_C void PodcastUtils::RemoveAllFormatting(TDes & aString)