[Webkit-unassigned] [Bug 44080] New: String find/reverseFind methods need tidying up

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Aug 16 16:10:04 PDT 2010


https://bugs.webkit.org/show_bug.cgi?id=44080

           Summary: String find/reverseFind methods need tidying up
           Product: WebKit
           Version: 528+ (Nightly build)
          Platform: PC
        OS/Version: Mac OS X 10.5
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: Web Template Framework
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: barraclough at apple.com


These methods have a couple of problems with their interface, and implementation.

These methods take and int index, and return an int – however this is problematic since on 64-bit string indices may have a full 32-bit range.  This spills out into surrounding code, which unsafely casts string indices from unsigned to int.  Code checking the result of these methods check for a mix of "== -1", "< 0", and "== notFound".  Clean this up by changing these methods to take an unsigned starting index, and return a size_t. with a failed match indicated by notFound.  reverseFind also has a special meaning for the starting index argument, in that a negative index is interpreted as an offset back from the end of the string.  Remove this functionality, in the (1!) case where it is used we should just calculate the offset by subtracting from the string's length.

The implementation has a few problems too.  The code is not in webkit style, in using assorted abbreviations in variable names, and implementations of similar find methods with differing argument types were unnecessarily inconsistent.  When find is passed const char* data the string would be handled as latin1 (zero extended to UTF-16) for all characters but the first; this is sign extended.  Case-insensitive find is broken for unicode strings; the hashing optimization is not unicode safe, and could result in false negatives.

Unify UString find methods to match String.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the webkit-unassigned mailing list