Gentoo Archives: gentoo-commits

From: Priit Laes <plaes@×××××.org>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/gnome:master commit in: net-libs/webkit-gtk/files/, net-libs/webkit-gtk/
Date: Fri, 25 Feb 2011 11:55:09
Message-Id: 4a112fc3e193f2a2fe8fad32b7ba7f8388e5f765.plaes@gentoo
1 commit: 4a112fc3e193f2a2fe8fad32b7ba7f8388e5f765
2 Author: Priit Laes <plaes <AT> plaes <DOT> org>
3 AuthorDate: Fri Feb 25 11:50:23 2011 +0000
4 Commit: Priit Laes <plaes <AT> plaes <DOT> org>
5 CommitDate: Fri Feb 25 11:50:23 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gnome.git;a=commit;h=4a112fc3
7
8 net-libs/webkit-gtk: Revbump to fix some issues in new utf-8 decoder
9
10 ---
11 .../files/webkit-gtk-1.3.12-utf-decode-v1.patch | 392 ++++++++++++++++++++
12 .../files/webkit-gtk-1.3.12-utf-decode-v2.patch | 44 +++
13 ...k-1.3.12.ebuild => webkit-gtk-1.3.12-r1.ebuild} | 3 +
14 3 files changed, 439 insertions(+), 0 deletions(-)
15
16 diff --git a/net-libs/webkit-gtk/files/webkit-gtk-1.3.12-utf-decode-v1.patch b/net-libs/webkit-gtk/files/webkit-gtk-1.3.12-utf-decode-v1.patch
17 new file mode 100644
18 index 0000000..ea1a961
19 --- /dev/null
20 +++ b/net-libs/webkit-gtk/files/webkit-gtk-1.3.12-utf-decode-v1.patch
21 @@ -0,0 +1,392 @@
22 +commit a4853e0b12ad2305ba7c3593a08f7f366dee5eaf
23 +Author: darin@×××××.com <darin@×××××.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
24 +Date: Wed Feb 23 20:00:25 2011 +0000
25 +
26 + 2011-02-23 Darin Adler <darin@×××××.com>
27 +
28 + Reviewed by Alexey Proskuryakov.
29 +
30 + REGRESSION (new UTF-8 decoder): Reproducible crash on alltommac.se
31 + https://bugs.webkit.org/show_bug.cgi?id=54862
32 +
33 + Correct handling of end of buffer partial sequence in UTF-8 and UTF-16 decoders when flushing with zero length
34 + https://bugs.webkit.org/show_bug.cgi?id=54444
35 +
36 + No new tests at this time. I will add some tests later, but since multiple
37 + people are hitting this I wanted to get it in as quickly as possible.
38 +
39 + * platform/text/TextCodecUTF16.cpp:
40 + (WebCore::TextCodecUTF16::decode): Tweaked coding style quite a bit.
41 + Removed special case for zero length now that main code handles it
42 + correctly. Used words instead of abbreviations for local variable names.
43 + Added error handling for a trailing byte.
44 +
45 + * platform/text/TextCodecUTF8.cpp:
46 + (WebCore::TextCodecUTF8::consumePartialSequenceByte): Added. Helper function
47 + to make the handleError and handlePartialSequence functions clearer.
48 + (WebCore::TextCodecUTF8::handleError): Added. Helper function to make the
49 + handlePartialSequence clearer.
50 + (WebCore::TextCodecUTF8::handlePartialSequence): Added. Factored out code for
51 + the partial sequence case. Making this a separate function probably helps make
52 + the fast case a little faster. This new version handles more cases correctly,
53 + which is what fixes the crashes we were seeing. In particular, it no longer
54 + assumes that the partial sequence is truly partial, because there are cases
55 + where we end up handling complete sequences here, such as when a complete
56 + sequence is inside a malformed partial sequence.
57 + (WebCore::TextCodecUTF8::decode): Removed partial sequence code and made this
58 + call handlePartialSequence instead. Could be streamlined if we double checked
59 + that passing a reference to "destination" and "source" doesn't harm code
60 + generation too much, so perhaps someone can do that research on a few compilers
61 + later and clean this up. Removed special case for zero length now that the
62 + main code handles that correctly.
63 +
64 + * platform/text/TextCodecUTF8.h: Added declarations for new functions.
65 + Made partial sequence buffer large enough to hold a whole sequence so we can
66 + use it to complete and decode a sequence in place.
67 +
68 +
69 + git-svn-id: http://svn.webkit.org/repository/webkit/trunk@79466 268f45cc-cd09-0410-ab3c-d52691b4dbfc
70 +
71 +diff --git a/Source/WebCore/platform/text/TextCodecUTF16.cpp b/Source/WebCore/platform/text/TextCodecUTF16.cpp
72 +index 4ceed23..f5dd59c 100644
73 +--- a/Source/WebCore/platform/text/TextCodecUTF16.cpp
74 ++++ b/Source/WebCore/platform/text/TextCodecUTF16.cpp
75 +@@ -1,5 +1,5 @@
76 + /*
77 +- * Copyright (C) 2004, 2006, 2008, 2010 Apple Inc. All rights reserved.
78 ++ * Copyright (C) 2004, 2006, 2008, 2010, 2011 Apple Inc. All rights reserved.
79 + *
80 + * Redistribution and use in source and binary forms, with or without
81 + * modification, are permitted provided that the following conditions
82 +@@ -27,10 +27,12 @@
83 + #include "TextCodecUTF16.h"
84 +
85 + #include "PlatformString.h"
86 ++#include <wtf/PassOwnPtr.h>
87 + #include <wtf/text/CString.h>
88 + #include <wtf/text/StringBuffer.h>
89 +-#include <wtf/PassOwnPtr.h>
90 ++#include <wtf/unicode/CharacterNames.h>
91 +
92 ++using namespace WTF::Unicode;
93 + using namespace std;
94 +
95 + namespace WebCore {
96 +@@ -52,12 +54,12 @@ void TextCodecUTF16::registerEncodingNames(EncodingNameRegistrar registrar)
97 +
98 + static PassOwnPtr<TextCodec> newStreamingTextDecoderUTF16LE(const TextEncoding&, const void*)
99 + {
100 +- return new TextCodecUTF16(true);
101 ++ return adoptPtr(new TextCodecUTF16(true));
102 + }
103 +
104 + static PassOwnPtr<TextCodec> newStreamingTextDecoderUTF16BE(const TextEncoding&, const void*)
105 + {
106 +- return new TextCodecUTF16(false);
107 ++ return adoptPtr(new TextCodecUTF16(false));
108 + }
109 +
110 + void TextCodecUTF16::registerCodecs(TextCodecRegistrar registrar)
111 +@@ -66,53 +68,56 @@ void TextCodecUTF16::registerCodecs(TextCodecRegistrar registrar)
112 + registrar("UTF-16BE", newStreamingTextDecoderUTF16BE, 0);
113 + }
114 +
115 +-String TextCodecUTF16::decode(const char* bytes, size_t length, bool, bool, bool&)
116 ++String TextCodecUTF16::decode(const char* bytes, size_t length, bool flush, bool stopOnError, bool& sawError)
117 + {
118 +- if (!length)
119 +- return String();
120 +-
121 +- // FIXME: This should generate an error if there is an unpaired surrogate.
122 ++ // FIXME: This should buffer surrogates, not just single bytes,
123 ++ // and should generate an error if there is an unpaired surrogate.
124 +
125 +- const unsigned char* p = reinterpret_cast<const unsigned char*>(bytes);
126 ++ const uint8_t* source = reinterpret_cast<const uint8_t*>(bytes);
127 + size_t numBytes = length + m_haveBufferedByte;
128 +- size_t numChars = numBytes / 2;
129 +-
130 +- StringBuffer buffer(numChars);
131 +- UChar* q = buffer.characters();
132 +-
133 +- if (m_haveBufferedByte) {
134 +- UChar c;
135 +- if (m_littleEndian)
136 +- c = m_bufferedByte | (p[0] << 8);
137 +- else
138 +- c = (m_bufferedByte << 8) | p[0];
139 +- *q++ = c;
140 +- m_haveBufferedByte = false;
141 +- p += 1;
142 +- numChars -= 1;
143 +- }
144 +-
145 +- if (m_littleEndian) {
146 +- for (size_t i = 0; i < numChars; ++i) {
147 +- UChar c = p[0] | (p[1] << 8);
148 +- p += 2;
149 +- *q++ = c;
150 ++ size_t numCharacters = numBytes / 2;
151 ++
152 ++ StringBuffer buffer(numCharacters + (flush && (numBytes & 1)));
153 ++ UChar* destination = buffer.characters();
154 ++
155 ++ if (length) {
156 ++ if (m_haveBufferedByte) {
157 ++ UChar character;
158 ++ if (m_littleEndian)
159 ++ *destination++ = m_bufferedByte | (source[0] << 8);
160 ++ else
161 ++ *destination++ = (m_bufferedByte << 8) | source[0];
162 ++ m_haveBufferedByte = false;
163 ++ ++source;
164 ++ --numCharacters;
165 + }
166 +- } else {
167 +- for (size_t i = 0; i < numChars; ++i) {
168 +- UChar c = (p[0] << 8) | p[1];
169 +- p += 2;
170 +- *q++ = c;
171 ++
172 ++ if (m_littleEndian) {
173 ++ for (size_t i = 0; i < numCharacters; ++i) {
174 ++ *destination++ = source[0] | (source[1] << 8);
175 ++ source += 2;
176 ++ }
177 ++ } else {
178 ++ for (size_t i = 0; i < numCharacters; ++i) {
179 ++ *destination++ = (source[0] << 8) | source[1];
180 ++ source += 2;
181 ++ }
182 + }
183 + }
184 +
185 + if (numBytes & 1) {
186 +- ASSERT(!m_haveBufferedByte);
187 +- m_haveBufferedByte = true;
188 +- m_bufferedByte = p[0];
189 ++ if (flush) {
190 ++ sawError = true;
191 ++ if (!stopOnError)
192 ++ *destination++ = replacementCharacter;
193 ++ } else {
194 ++ ASSERT(!m_haveBufferedByte);
195 ++ m_haveBufferedByte = true;
196 ++ m_bufferedByte = source[0];
197 ++ }
198 + }
199 +-
200 +- buffer.shrink(q - buffer.characters());
201 ++
202 ++ buffer.shrink(destination - buffer.characters());
203 +
204 + return String::adopt(buffer);
205 + }
206 +@@ -134,15 +139,15 @@ CString TextCodecUTF16::encode(const UChar* characters, size_t length, Unencodab
207 + // null characters inside it. Perhaps the result of encode should not be a CString.
208 + if (m_littleEndian) {
209 + for (size_t i = 0; i < length; ++i) {
210 +- UChar c = characters[i];
211 +- bytes[i * 2] = c;
212 +- bytes[i * 2 + 1] = c >> 8;
213 ++ UChar character = characters[i];
214 ++ bytes[i * 2] = character;
215 ++ bytes[i * 2 + 1] = character >> 8;
216 + }
217 + } else {
218 + for (size_t i = 0; i < length; ++i) {
219 +- UChar c = characters[i];
220 +- bytes[i * 2] = c >> 8;
221 +- bytes[i * 2 + 1] = c;
222 ++ UChar character = characters[i];
223 ++ bytes[i * 2] = character >> 8;
224 ++ bytes[i * 2 + 1] = character;
225 + }
226 + }
227 +
228 +diff --git a/Source/WebCore/platform/text/TextCodecUTF8.cpp b/Source/WebCore/platform/text/TextCodecUTF8.cpp
229 +index 2466e8c..29426ad 100644
230 +--- a/Source/WebCore/platform/text/TextCodecUTF8.cpp
231 ++++ b/Source/WebCore/platform/text/TextCodecUTF8.cpp
232 +@@ -150,11 +150,71 @@ static inline UChar* appendCharacter(UChar* destination, int character)
233 + return destination;
234 + }
235 +
236 +-String TextCodecUTF8::decode(const char* bytes, size_t length, bool flush, bool stopOnError, bool& sawError)
237 ++void TextCodecUTF8::consumePartialSequenceByte()
238 + {
239 +- if (!length)
240 +- return String();
241 ++ --m_partialSequenceSize;
242 ++ memmove(m_partialSequence, m_partialSequence + 1, m_partialSequenceSize);
243 ++}
244 +
245 ++void TextCodecUTF8::handleError(UChar*& destination, bool stopOnError, bool& sawError)
246 ++{
247 ++ sawError = true;
248 ++ if (stopOnError)
249 ++ return;
250 ++ // Each error generates a replacement character and consumes one byte.
251 ++ *destination++ = replacementCharacter;
252 ++ consumePartialSequenceByte();
253 ++}
254 ++
255 ++void TextCodecUTF8::handlePartialSequence(UChar*& destination, const uint8_t*& source, const uint8_t* end, bool flush, bool stopOnError, bool& sawError)
256 ++{
257 ++ ASSERT(m_partialSequenceSize);
258 ++ do {
259 ++ if (isASCII(m_partialSequence[0])) {
260 ++ *destination++ = m_partialSequence[0];
261 ++ consumePartialSequenceByte();
262 ++ continue;
263 ++ }
264 ++ int count = nonASCIISequenceLength(m_partialSequence[0]);
265 ++ if (!count) {
266 ++ handleError(destination, stopOnError, sawError);
267 ++ if (stopOnError)
268 ++ return;
269 ++ continue;
270 ++ }
271 ++ if (count > m_partialSequenceSize) {
272 ++ if (count - m_partialSequenceSize > end - source) {
273 ++ if (!flush) {
274 ++ // The new data is not enough to complete the sequence, so
275 ++ // add it to the existing partial sequence.
276 ++ memcpy(m_partialSequence + m_partialSequenceSize, source, end - source);
277 ++ m_partialSequenceSize += end - source;
278 ++ return;
279 ++ }
280 ++ // An incomplete partial sequence at the end is an error.
281 ++ handleError(destination, stopOnError, sawError);
282 ++ if (stopOnError)
283 ++ return;
284 ++ continue;
285 ++ }
286 ++ memcpy(m_partialSequence + m_partialSequenceSize, source, count - m_partialSequenceSize);
287 ++ source += count - m_partialSequenceSize;
288 ++ m_partialSequenceSize = count;
289 ++ }
290 ++ int character = decodeNonASCIISequence(m_partialSequence, count);
291 ++ if (character == nonCharacter) {
292 ++ handleError(destination, stopOnError, sawError);
293 ++ if (stopOnError)
294 ++ return;
295 ++ continue;
296 ++ }
297 ++ m_partialSequenceSize -= count;
298 ++ destination = appendCharacter(destination, character);
299 ++ } while (m_partialSequenceSize);
300 ++}
301 ++
302 ++String TextCodecUTF8::decode(const char* bytes, size_t length, bool flush, bool stopOnError, bool& sawError)
303 ++{
304 + // Each input byte might turn into a character.
305 + // That includes all bytes in the partial-sequence buffer because
306 + // each byte in an invalid sequence will turn into a replacement character.
307 +@@ -166,52 +226,19 @@ String TextCodecUTF8::decode(const char* bytes, size_t length, bool flush, bool
308 + UChar* destination = buffer.characters();
309 +
310 + do {
311 +- while (m_partialSequenceSize) {
312 +- int count = nonASCIISequenceLength(m_partialSequence[0]);
313 +- ASSERT(count > m_partialSequenceSize);
314 +- ASSERT(count >= 2);
315 +- ASSERT(count <= 4);
316 +- if (count - m_partialSequenceSize > end - source) {
317 +- if (!flush) {
318 +- // We have an incomplete partial sequence, so put it all in the partial
319 +- // sequence buffer, and break out of this loop so we can exit the function.
320 +- memcpy(m_partialSequence + m_partialSequenceSize, source, end - source);
321 +- m_partialSequenceSize += end - source;
322 +- source = end;
323 +- break;
324 +- }
325 +- // We have an incomplete partial sequence at the end of the buffer.
326 +- // That is an error.
327 +- sawError = true;
328 +- if (stopOnError) {
329 +- source = end;
330 +- break;
331 +- }
332 +- // Each error consumes one byte and generates one replacement character.
333 +- --m_partialSequenceSize;
334 +- memmove(m_partialSequence, m_partialSequence + 1, m_partialSequenceSize);
335 +- *destination++ = replacementCharacter;
336 +- continue;
337 ++ if (m_partialSequenceSize) {
338 ++ // Explicitly copy destination and source to avoid taking a pointer to them,
339 ++ // which may harm code generation.
340 ++ UChar* destinationForHandlePartialSequence = destination;
341 ++ const uint8_t* sourceForHandlePartialSequence = source;
342 ++ handlePartialSequence(destinationForHandlePartialSequence, sourceForHandlePartialSequence, end, flush, stopOnError, sawError);
343 ++ destination = destinationForHandlePartialSequence;
344 ++ source = sourceForHandlePartialSequence;
345 ++ if (m_partialSequenceSize) {
346 ++ ASSERT(stopOnError);
347 ++ ASSERT(sawError);
348 ++ break;
349 + }
350 +- uint8_t completeSequence[U8_MAX_LENGTH];
351 +- memcpy(completeSequence, m_partialSequence, m_partialSequenceSize);
352 +- memcpy(completeSequence + m_partialSequenceSize, source, count - m_partialSequenceSize);
353 +- source += count - m_partialSequenceSize;
354 +- int character = decodeNonASCIISequence(completeSequence, count);
355 +- if (character == nonCharacter) {
356 +- sawError = true;
357 +- if (stopOnError) {
358 +- source = end;
359 +- break;
360 +- }
361 +- // Each error consumes one byte and generates one replacement character.
362 +- memcpy(m_partialSequence, completeSequence + 1, count - 1);
363 +- m_partialSequenceSize = count - 1;
364 +- *destination++ = replacementCharacter;
365 +- continue;
366 +- }
367 +- m_partialSequenceSize = 0;
368 +- destination = appendCharacter(destination, character);
369 + }
370 +
371 + while (source < end) {
372 +@@ -239,10 +266,8 @@ String TextCodecUTF8::decode(const char* bytes, size_t length, bool flush, bool
373 + if (!count)
374 + character = nonCharacter;
375 + else {
376 +- ASSERT(count >= 2);
377 +- ASSERT(count <= 4);
378 + if (count > end - source) {
379 +- ASSERT(end - source <= static_cast<ptrdiff_t>(sizeof(m_partialSequence)));
380 ++ ASSERT(end - source < static_cast<ptrdiff_t>(sizeof(m_partialSequence)));
381 + ASSERT(!m_partialSequenceSize);
382 + m_partialSequenceSize = end - source;
383 + memcpy(m_partialSequence, source, m_partialSequenceSize);
384 +@@ -255,9 +280,9 @@ String TextCodecUTF8::decode(const char* bytes, size_t length, bool flush, bool
385 + sawError = true;
386 + if (stopOnError)
387 + break;
388 +- // Each error consumes one byte and generates one replacement character.
389 +- ++source;
390 ++ // Each error generates a replacement character and consumes one byte.
391 + *destination++ = replacementCharacter;
392 ++ ++source;
393 + continue;
394 + }
395 + source += count;
396 +diff --git a/Source/WebCore/platform/text/TextCodecUTF8.h b/Source/WebCore/platform/text/TextCodecUTF8.h
397 +index 2bbb31e..39fd753 100644
398 +--- a/Source/WebCore/platform/text/TextCodecUTF8.h
399 ++++ b/Source/WebCore/platform/text/TextCodecUTF8.h
400 +@@ -42,8 +42,12 @@ private:
401 + virtual String decode(const char*, size_t length, bool flush, bool stopOnError, bool& sawError);
402 + virtual CString encode(const UChar*, size_t length, UnencodableHandling);
403 +
404 ++ void handlePartialSequence(UChar*& destination, const uint8_t*& source, const uint8_t* end, bool flush, bool stopOnError, bool& sawError);
405 ++ void handleError(UChar*& destination, bool stopOnError, bool& sawError);
406 ++ void consumePartialSequenceByte();
407 ++
408 + int m_partialSequenceSize;
409 +- char m_partialSequence[U8_MAX_LENGTH - 1];
410 ++ uint8_t m_partialSequence[U8_MAX_LENGTH];
411 +
412 + };
413 +
414
415 diff --git a/net-libs/webkit-gtk/files/webkit-gtk-1.3.12-utf-decode-v2.patch b/net-libs/webkit-gtk/files/webkit-gtk-1.3.12-utf-decode-v2.patch
416 new file mode 100644
417 index 0000000..7fb9a46
418 --- /dev/null
419 +++ b/net-libs/webkit-gtk/files/webkit-gtk-1.3.12-utf-decode-v2.patch
420 @@ -0,0 +1,44 @@
421 +commit 3f28cee7ffa83df4510b234af13c223714b9324c
422 +Author: darin@×××××.com <darin@×××××.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
423 +Date: Fri Feb 25 02:20:42 2011 +0000
424 +
425 + 2011-02-24 Darin Adler <darin@×××××.com>
426 +
427 + Reviewed by Alexey Proskuryakov.
428 +
429 + REGRESSION (r79466): http/tests/incremental/slow-utf8-html.pl flaky due to incorrect assertions
430 + https://bugs.webkit.org/show_bug.cgi?id=55135
431 +
432 + * platform/text/TextCodecUTF8.cpp:
433 + (WebCore::TextCodecUTF8::decode): Removed incorrect assertions.
434 +
435 +
436 + git-svn-id: http://svn.webkit.org/repository/webkit/trunk@79655 268f45cc-cd09-0410-ab3c-d52691b4dbfc
437 +
438 +diff --git a/Source/WebCore/platform/text/TextCodecUTF8.cpp b/Source/WebCore/platform/text/TextCodecUTF8.cpp
439 +index 29426ad..5f82092 100644
440 +--- a/Source/WebCore/platform/text/TextCodecUTF8.cpp
441 ++++ b/Source/WebCore/platform/text/TextCodecUTF8.cpp
442 +@@ -227,18 +227,16 @@ String TextCodecUTF8::decode(const char* bytes, size_t length, bool flush, bool
443 +
444 + do {
445 + if (m_partialSequenceSize) {
446 +- // Explicitly copy destination and source to avoid taking a pointer to them,
447 +- // which may harm code generation.
448 ++ // Explicitly copy destination and source pointers to avoid taking pointers to the
449 ++ // local variables, which may harm code generation by disabling some optimizations
450 ++ // in some compilers.
451 + UChar* destinationForHandlePartialSequence = destination;
452 + const uint8_t* sourceForHandlePartialSequence = source;
453 + handlePartialSequence(destinationForHandlePartialSequence, sourceForHandlePartialSequence, end, flush, stopOnError, sawError);
454 + destination = destinationForHandlePartialSequence;
455 + source = sourceForHandlePartialSequence;
456 +- if (m_partialSequenceSize) {
457 +- ASSERT(stopOnError);
458 +- ASSERT(sawError);
459 ++ if (m_partialSequenceSize)
460 + break;
461 +- }
462 + }
463 +
464 + while (source < end) {
465
466 diff --git a/net-libs/webkit-gtk/webkit-gtk-1.3.12.ebuild b/net-libs/webkit-gtk/webkit-gtk-1.3.12-r1.ebuild
467 similarity index 97%
468 rename from net-libs/webkit-gtk/webkit-gtk-1.3.12.ebuild
469 rename to net-libs/webkit-gtk/webkit-gtk-1.3.12-r1.ebuild
470 index 9603900..6c259f3 100644
471 --- a/net-libs/webkit-gtk/webkit-gtk-1.3.12.ebuild
472 +++ b/net-libs/webkit-gtk/webkit-gtk-1.3.12-r1.ebuild
473 @@ -60,6 +60,9 @@ src_prepare() {
474 # https://bugs.webkit.org/show_bug.cgi?id=19775
475 use sparc && epatch "${FILESDIR}"/${PN}-1.1.15.2-unaligned.patch
476
477 + epatch "${FILESDIR}/${P}-utf-decode-v1.patch"
478 + epatch "${FILESDIR}/${P}-utf-decode-v2.patch"
479 +
480 # Darwin/Aqua build is broken, needs autoreconf
481 # XXX: BROKEN. Patch does not apply anymore.
482 # https://bugs.webkit.org/show_bug.cgi?id=28727