One more round of simplification and fixing.

git-svn-id: http://svn.haiku-os.org/webpositive/webkit/trunk@407 94f232f2-1747-11df-bad5-a5bfde151594
This commit is contained in:
stippi
2012-07-03 15:40:17 +02:00
committed by Alexandre Deckner
parent f9977c07c1
commit a26e66b548
+12 -18
View File
@@ -317,25 +317,19 @@ void
URLInputGroup::URLTextView::InsertText(const char* inText, int32 inLength,
int32 inOffset, const text_run_array* inRuns)
{
char* buffer = NULL;
if (strpbrk(inText, "\r\n") && inLength <= 1024) {
buffer = (char*)malloc(inLength + 1);
if (buffer) {
strlcpy(buffer, inText, inLength + 1);
for (int32 i = 0; i < inLength; i++) {
if (buffer[i] == '\r' || buffer[i] == '\n')
buffer[i] = ' ';
}
}
// Filter all line breaks, note that inText is not terminated.
if (inLength == 1) {
if (*inText == '\n' || *inText == '\r')
BTextView::InsertText(" ", 1, inOffset, inRuns);
else
BTextView::InsertText(inText, 1, inOffset, inRuns);
} else {
BString filteredText(inText, inLength);
filteredText.ReplaceAll('\n', ' ');
filteredText.ReplaceAll('\r', ' ');
BTextView::InsertText(filteredText.String(), inLength, inOffset,
inRuns);
}
BTextView::InsertText(buffer ? buffer : inText, inLength, inOffset,
inRuns);
free(buffer);
}