[SCM] WebKit Debian packaging branch, webkit-1.3, updated. upstream/1.3.7-4207-g178b198

mario at webkit.org mario at webkit.org
Sun Feb 20 23:55:49 UTC 2011


The following commit has been merged in the webkit-1.3 branch:
commit 1ce6fd187f8892df2a9b0a36fbfffe869cd925b1
Author: mario at webkit.org <mario at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Jan 26 22:43:44 2011 +0000

    2011-01-26  Mario Sanchez Prada  <msanchez at igalia.com>
    
            Reviewed by Martin Robinson.
    
            [GTK] Reliable crash with getTextAtOffset()
            https://bugs.webkit.org/show_bug.cgi?id=53131
    
            Properly calculate length in bytes for a UTF8 substring.
    
            * accessibility/gtk/AccessibilityObjectWrapperAtk.cpp:
            (utf8Substr): Use character instead of bytes as units to
            calculate the length in bytes for the UTF8 string.
    2011-01-26  Mario Sanchez Prada  <msanchez at igalia.com>
    
            Reviewed by Martin Robinson.
    
            [GTK] Reliable crash with getTextAtOffset()
            https://bugs.webkit.org/show_bug.cgi?id=53131
    
            New unit test to check the fix for this bug.
    
            * tests/testatk.c:
            (testWebkitAtkGetTextAtOffsetWithSpecialCharacters): New.
            (main): Add new unit test.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76721 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 7f57c49..3863068 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,16 @@
+2011-01-26  Mario Sanchez Prada  <msanchez at igalia.com>
+
+        Reviewed by Martin Robinson.
+
+        [GTK] Reliable crash with getTextAtOffset()
+        https://bugs.webkit.org/show_bug.cgi?id=53131
+
+        Properly calculate length in bytes for a UTF8 substring.
+
+        * accessibility/gtk/AccessibilityObjectWrapperAtk.cpp:
+        (utf8Substr): Use character instead of bytes as units to
+        calculate the length in bytes for the UTF8 string.
+
 2011-01-25  Dimitri Glazkov  <dglazkov at chromium.org>
 
         Reviewed by Kent Tamura.
diff --git a/Source/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp b/Source/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp
index 692decd..de3b324 100644
--- a/Source/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp
+++ b/Source/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp
@@ -994,7 +994,7 @@ static gchar* utf8Substr(const gchar* string, gint start, gint end)
     if (start > strLen || end > strLen)
         return 0;
     gchar* startPtr = g_utf8_offset_to_pointer(string, start);
-    gsize lenInBytes = g_utf8_offset_to_pointer(string, end) -  startPtr + 1;
+    gsize lenInBytes = g_utf8_offset_to_pointer(string, end + 1) -  startPtr;
     gchar* output = static_cast<gchar*>(g_malloc0(lenInBytes + 1));
     return g_utf8_strncpy(output, startPtr, end - start + 1);
 }
diff --git a/Source/WebKit/gtk/ChangeLog b/Source/WebKit/gtk/ChangeLog
index 912c948..1f4e31c 100644
--- a/Source/WebKit/gtk/ChangeLog
+++ b/Source/WebKit/gtk/ChangeLog
@@ -1,3 +1,16 @@
+2011-01-26  Mario Sanchez Prada  <msanchez at igalia.com>
+
+        Reviewed by Martin Robinson.
+
+        [GTK] Reliable crash with getTextAtOffset()
+        https://bugs.webkit.org/show_bug.cgi?id=53131
+
+        New unit test to check the fix for this bug.
+
+        * tests/testatk.c:
+        (testWebkitAtkGetTextAtOffsetWithSpecialCharacters): New.
+        (main): Add new unit test.
+
 2011-01-21  Carlos Garcia Campos  <cgarcia at igalia.com>
 
         Reviewed by Martin Robinson.
diff --git a/Source/WebKit/gtk/tests/testatk.c b/Source/WebKit/gtk/tests/testatk.c
index 1ee6c55..eb48fc7 100644
--- a/Source/WebKit/gtk/tests/testatk.c
+++ b/Source/WebKit/gtk/tests/testatk.c
@@ -32,6 +32,8 @@ static const char* contents = "<html><body><p>This is a test. This is the second
 
 static const char* contentsWithNewlines = "<html><body><p>This is a test. \n\nThis\n is the second sentence. And this the third.</p></body></html>";
 
+static const char* contentsWithSpecialChars = "<html><body><p>&laquo;&nbsp;This is a paragraph with &ldquo;special&rdquo; characters inside.&nbsp;&raquo;</p></body></html>";
+
 static const char* contentsInTextarea = "<html><body><textarea cols='80'>This is a test. This is the second sentence. And this the third.</textarea></body></html>";
 
 static const char* contentsInTextInput = "<html><body><input type='text' size='80' value='This is a test. This is the second sentence. And this the third.'/></body></html>";
@@ -453,6 +455,40 @@ static void testWebkitAtkGetTextAtOffsetTextInput()
     g_object_unref(webView);
 }
 
+static void testWebkitAtkGetTextAtOffsetWithSpecialCharacters()
+{
+    WebKitWebView* webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
+    g_object_ref_sink(webView);
+    GtkAllocation allocation = { 0, 0, 800, 600 };
+    gtk_widget_size_allocate(GTK_WIDGET(webView), &allocation);
+    webkit_web_view_load_string(webView, contentsWithSpecialChars, 0, 0, 0);
+
+    /* Wait for the accessible objects to be created. */
+    waitForAccessibleObjects();
+
+    /* Get to the inner AtkText object. */
+    AtkObject* object = gtk_widget_get_accessible(GTK_WIDGET(webView));
+    g_assert(object);
+    object = atk_object_ref_accessible_child(object, 0);
+    g_assert(object);
+
+    AtkText* textObject = ATK_TEXT(object);
+    g_assert(ATK_IS_TEXT(textObject));
+
+    const gchar* expectedText = "\302\253\302\240This is a paragraph with \342\200\234special\342\200\235 characters inside.\302\240\302\273";
+    char* text = atk_text_get_text(textObject, 0, -1);
+    g_assert_cmpstr(text, ==, expectedText);
+    g_free(text);
+
+    /* Check that getting the text with ATK_TEXT_BOUNDARY_LINE_START
+       and ATK_TEXT_BOUNDARY_LINE_END does not crash because of not
+       properly handling characters inside the UTF-8 string. */
+    testGetTextFunction(textObject, atk_text_get_text_at_offset, ATK_TEXT_BOUNDARY_LINE_START, 0, expectedText, 0, 57);
+    testGetTextFunction(textObject, atk_text_get_text_at_offset, ATK_TEXT_BOUNDARY_LINE_END, 0, expectedText, 0, 57);
+
+    g_object_unref(webView);
+}
+
 static void testWebkitAtkGetTextInParagraphAndBodySimple()
 {
     WebKitWebView* webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
@@ -1320,6 +1356,7 @@ int main(int argc, char** argv)
     g_test_add_func("/webkit/atk/getTextAtOffsetNewlines", testWebkitAtkGetTextAtOffsetNewlines);
     g_test_add_func("/webkit/atk/getTextAtOffsetTextarea", testWebkitAtkGetTextAtOffsetTextarea);
     g_test_add_func("/webkit/atk/getTextAtOffsetTextInput", testWebkitAtkGetTextAtOffsetTextInput);
+    g_test_add_func("/webkit/atk/getTextAtOffsetWithSpecialCharacters", testWebkitAtkGetTextAtOffsetWithSpecialCharacters);
     g_test_add_func("/webkit/atk/getTextInParagraphAndBodySimple", testWebkitAtkGetTextInParagraphAndBodySimple);
     g_test_add_func("/webkit/atk/getTextInParagraphAndBodyModerate", testWebkitAtkGetTextInParagraphAndBodyModerate);
     g_test_add_func("/webkit/atk/getTextInTable", testWebkitAtkGetTextInTable);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list