Overview
Comment: | Skip possible BOMs in OFMutableString. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | 0.5 |
Files: | files | file ages | folders |
SHA3-256: |
810b0028edf6a42e2fb1203e5f3cd691 |
User & Date: | js on 2011-04-25 17:17:16 |
Other Links: | branch diff | manifest | tags |
Context
2011-04-25
| ||
18:04 | Set version to 0.5.2. check-in: 4c15904184 user: js tags: 0.5 | |
17:17 | Skip possible BOMs in OFMutableString. check-in: 810b0028ed user: js tags: 0.5 | |
14:14 | Fix a warning when sizeof(size_t) < sizeof(long long). check-in: abff9ac184 user: js tags: 0.5 | |
Changes
Modified src/OFMutableString.m from [4ddd782651] to [6944810146].
︙ | ︙ | |||
133 134 135 136 137 138 139 140 141 142 143 144 145 146 | - (void)setToCString: (const char*)str { size_t len; [self freeMemory: string]; len = strlen(str); switch (of_string_check_utf8(str, len)) { case 0: isUTF8 = NO; break; case 1: isUTF8 = YES; | > > > > > | 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | - (void)setToCString: (const char*)str { size_t len; [self freeMemory: string]; len = strlen(str); if (len >= 3 && !memcmp(str, "\xEF\xBB\xBF", 3)) { str += 3; len -= 3; } switch (of_string_check_utf8(str, len)) { case 0: isUTF8 = NO; break; case 1: isUTF8 = YES; |
︙ | ︙ | |||
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | } - (void)appendCString: (const char*)str { size_t strlength; strlength = strlen(str); switch (of_string_check_utf8(str, strlength)) { case 1: isUTF8 = YES; break; case -1: @throw [OFInvalidEncodingException newWithClass: isa]; } string = [self resizeMemory: string toSize: length + strlength + 1]; memcpy(string + length, str, strlength + 1); length += strlength; } - (void)appendCString: (const char*)str withLength: (size_t)len { switch (of_string_check_utf8(str, len)) { case 1: isUTF8 = YES; break; case -1: @throw [OFInvalidEncodingException newWithClass: isa]; } | > > > > > > > > > > | 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | } - (void)appendCString: (const char*)str { size_t strlength; strlength = strlen(str); if (strlength >= 3 && !memcmp(str, "\xEF\xBB\xBF", 3)) { str += 3; strlength -= 3; } switch (of_string_check_utf8(str, strlength)) { case 1: isUTF8 = YES; break; case -1: @throw [OFInvalidEncodingException newWithClass: isa]; } string = [self resizeMemory: string toSize: length + strlength + 1]; memcpy(string + length, str, strlength + 1); length += strlength; } - (void)appendCString: (const char*)str withLength: (size_t)len { if (len >= 3 && !memcmp(str, "\xEF\xBB\xBF", 3)) { str += 3; len -= 3; } switch (of_string_check_utf8(str, len)) { case 1: isUTF8 = YES; break; case -1: @throw [OFInvalidEncodingException newWithClass: isa]; } |
︙ | ︙ |
Modified tests/OFStringTests.m from [f41872f1e2] to [ac5088ce3b].
︙ | ︙ | |||
133 134 135 136 137 138 139 | TEST(@"+[stringWithContentsOfURL:encoding]", (s[1] = [OFString stringWithContentsOfURL: [OFURL URLWithString: @"file://testfile.txt"] encoding: OF_STRING_ENCODING_ISO_8859_1]) && [s[1] isEqual: @"testäöü"]) TEST(@"-[appendCStringWithLength:]", | | | | 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | TEST(@"+[stringWithContentsOfURL:encoding]", (s[1] = [OFString stringWithContentsOfURL: [OFURL URLWithString: @"file://testfile.txt"] encoding: OF_STRING_ENCODING_ISO_8859_1]) && [s[1] isEqual: @"testäöü"]) TEST(@"-[appendCStringWithLength:]", R([s[0] appendCString: "foo\xEF\xBB\xBF" "barqux" + 3 withLength: 6]) && [s[0] isEqual: @"foobar"]) EXPECT_EXCEPTION(@"Detection of invalid UTF-8 encoding #1", OFInvalidEncodingException, [OFString stringWithCString: "\xE0\x80"]) EXPECT_EXCEPTION(@"Detection of invalid UTF-8 encoding #2", OFInvalidEncodingException, [OFString stringWithCString: "\xF0\x80\x80\xC0"]) |
︙ | ︙ |