Summary: | [GTK] Implementation of atk_editable_text_insert_text ignores 'length' parameter | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Mario Sanchez Prada <mario> | ||||||
Component: | WebKitGTK | Assignee: | Mario Sanchez Prada <mario> | ||||||
Status: | RESOLVED FIXED | ||||||||
Severity: | Normal | CC: | cgarcia | ||||||
Priority: | P2 | Keywords: | Gtk | ||||||
Version: | 528+ (Nightly build) | ||||||||
Hardware: | Unspecified | ||||||||
OS: | Unspecified | ||||||||
Attachments: |
|
Description
Mario Sanchez Prada
2012-08-13 01:40:20 PDT
Created attachment 157941 [details]
Patch proposal
Attaching a simple patch to fix this issue
Comment on attachment 157941 [details] Patch proposal View in context: https://bugs.webkit.org/attachment.cgi?id=157941&action=review > Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceEditableText.cpp:78 > + if (document->frame()->editor()->insertTextWithoutSendingTextEvent(String::fromUTF8(string).substring(0, length), false, 0)) I'm not sure this is always correct, according to the ATK api docs, length is the size in bytes, so maybe we should get the substring before converting the string from utf8 to utf16. You could do something like: if (document->frame()->editor()->insertTextWithoutSendingTextEvent(String::fromUTF8(CString(string, length)).data(), false, 0)) Created attachment 157944 [details]
Patch proposal
I think Carlos had a point here. Attaching a new patch (tested)
Comment on attachment 157944 [details] Patch proposal View in context: https://bugs.webkit.org/attachment.cgi?id=157944&action=review > Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceEditableText.cpp:78 > - if (document->frame()->editor()->insertTextWithoutSendingTextEvent(String::fromUTF8(string), false, 0)) > + if (document->frame()->editor()->insertTextWithoutSendingTextEvent(String::fromUTF8(CString(string, length).data()), false, 0)) Now might also be a good time to return early if the string is null, as the comment above suggests. It's always a good idea to be distrustful of data from outside the library. (In reply to comment #4) > (From update of attachment 157944 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=157944&action=review > > > Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceEditableText.cpp:78 > > - if (document->frame()->editor()->insertTextWithoutSendingTextEvent(String::fromUTF8(string), false, 0)) > > + if (document->frame()->editor()->insertTextWithoutSendingTextEvent(String::fromUTF8(CString(string, length).data()), false, 0)) > > Now might also be a good time to return early if the string is null, as the comment above suggests. It's always a good idea to be distrustful of data from outside the library. I agree it would be good to fix the FIXME, but probably as a separate bug, since it's a different issue. (In reply to comment #5) > (In reply to comment #4) > > (From update of attachment 157944 [details] [details]) > > View in context: https://bugs.webkit.org/attachment.cgi?id=157944&action=review > > > > > Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceEditableText.cpp:78 > > > - if (document->frame()->editor()->insertTextWithoutSendingTextEvent(String::fromUTF8(string), false, 0)) > > > + if (document->frame()->editor()->insertTextWithoutSendingTextEvent(String::fromUTF8(CString(string, length).data()), false, 0)) > > > > Now might also be a good time to return early if the string is null, as the comment above suggests. It's always a good idea to be distrustful of data from outside the library. > > I agree it would be good to fix the FIXME, but probably as a separate bug, since it's a different issue. As it's just an early return, I'd go for it now, not in a separate bug. I'll do it when landing Committed r125403: <http://trac.webkit.org/changeset/125403> |