diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-10 02:29:01 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-10 02:29:01 +0000 |
commit | f4288b5cd64d368fd603b9564c3c0448729b31c6 (patch) | |
tree | cdc7bbcb3b94d563346bbbc5b60a6b4c30a663f3 /app | |
parent | ad190ea2a1fb35f61ed73b122b6e088bdf7116b7 (diff) | |
download | chromium_src-f4288b5cd64d368fd603b9564c3c0448729b31c6.zip chromium_src-f4288b5cd64d368fd603b9564c3c0448729b31c6.tar.gz chromium_src-f4288b5cd64d368fd603b9564c3c0448729b31c6.tar.bz2 |
GTK - don't paste a garbage text/html character.
When the clipboard text/html data terminates with NULL, drop it (WebKit used to do this for us before the parsing changed in roll 61629:61653). Some programs such as open office NULL terminate clipboard text/html data, even though it is unnecessary since the clipboard api provides a length for the data buffer. Chrome also NULL terminates text/html data in order to work around a bug in some versions of pidgin.
Also, don't NULL terminate text/plain data, because no app I tested (firefox, gedit, midori, konqueror, OO) does this.
BUG=48335
TEST=manual (see bug)
Review URL: http://codereview.chromium.org/2896006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52034 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app')
-rw-r--r-- | app/clipboard/clipboard_linux.cc | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/app/clipboard/clipboard_linux.cc b/app/clipboard/clipboard_linux.cc index 71a429f..56d359f 100644 --- a/app/clipboard/clipboard_linux.cc +++ b/app/clipboard/clipboard_linux.cc @@ -153,9 +153,8 @@ void Clipboard::SetGtkClipboard() { } void Clipboard::WriteText(const char* text_data, size_t text_len) { - char* data = new char[text_len + 1]; + char* data = new char[text_len]; memcpy(data, text_data, text_len); - data[text_len] = '\0'; InsertMapping(kMimeText, data, text_len); InsertMapping("TEXT", data, text_len); @@ -177,6 +176,7 @@ void Clipboard::WriteHTML(const char* markup_data, char* data = new char[total_len]; snprintf(data, total_len, "%s", html_prefix); memcpy(data + html_prefix_len, markup_data, markup_len); + // Some programs expect NULL-terminated data. See http://crbug.com/42624 data[total_len - 1] = '\0'; InsertMapping(kMimeHtml, data, total_len); @@ -350,6 +350,10 @@ void Clipboard::ReadHTML(Clipboard::Buffer buffer, string16* markup, UTF8ToUTF16(reinterpret_cast<char*>(data->data), data->length, markup); } + // If there is a terminating NULL, drop it. + if (markup->at(markup->length() - 1) == '\0') + markup->resize(markup->length() - 1); + gtk_selection_data_free(data); } |