Author: stippi Date: Mon Apr 12 16:57:03 2010 New Revision: 407 URL: http://mmlr.dyndns.org/changeset/407 Log: One more round of simplification and fixing. Modified: webkit/trunk/WebKit/haiku/WebPositive/URLInputGroup.cpp Modified: webkit/trunk/WebKit/haiku/WebPositive/URLInputGroup.cpp ============================================================================== --- webkit/trunk/WebKit/haiku/WebPositive/URLInputGroup.cpp Mon Apr 12 16:16:40 2010 (r406) +++ webkit/trunk/WebKit/haiku/WebPositive/URLInputGroup.cpp Mon Apr 12 16:57:03 2010 (r407) @@ -317,25 +317,19 @@ 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); }