Commit 41dfe13d authored by Stuart Langley's avatar Stuart Langley Committed by Commit Bot

Fix regression introduced into copying images using the clipboard.

The mojo work for web clipboard has introduced a regression when copying
images. Originally the code was in content and was using net::EscapeForHTML
to escape the URL of the image and the title.

When converted to mojo and moved inside of blink this was changed to
EncodeWithURLEscapeSequences which is a different encoding scheme.

This change reverts to using an escaping the same as net::EscapeForHTML,
however as net::EscapeForHTML uses std::string and we are working with
WTF::String we have had to copy the code rather than re-use it.

Bug: 806076
Change-Id: Ic51835c555c071571a837018d74a27fd455362cf
Reviewed-on: https://chromium-review.googlesource.com/896762
Commit-Queue: Stuart Langley <slangley@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#534858}
parent ec4e7f70
......@@ -36,6 +36,7 @@ include_rules = [
"+base/trace_event",
"+base/values.h",
"+base/lazy_instance.h",
"+net/base/escape.h",
"+net/http/http_util.h",
"+net/http/http_request_headers.h",
"+net/http/http_response_headers.h",
......
......@@ -6,10 +6,12 @@
#include "build/build_config.h"
#include "mojo/public/cpp/system/platform_handle.h"
#include "net/base/escape.h"
#include "public/platform/Platform.h"
#include "services/service_manager/public/cpp/connector.h"
#include "third_party/WebKit/Source/platform/blob/BlobData.h"
#include "third_party/WebKit/Source/platform/clipboard/ClipboardMimeTypes.h"
#include "third_party/WebKit/Source/platform/wtf/text/StringUTF8Adaptor.h"
#include "third_party/WebKit/public/platform/WebDragData.h"
#include "third_party/WebKit/public/platform/WebImage.h"
#include "third_party/WebKit/public/platform/WebSize.h"
......@@ -53,16 +55,21 @@ DragData BuildDragData(const WebDragData& web_drag_data) {
};
#if !defined(OS_MACOSX)
String EscapeForHTML(const String& str) {
std::string output =
net::EscapeForHTML(StringUTF8Adaptor(str).AsStringPiece());
return String(output.c_str());
}
// TODO(slangley): crbug.com/775830 Remove the implementation of
// URLToImageMarkup from clipboard_utils.h once we can delete
// MockWebClipboardImpl.
WTF::String URLToImageMarkup(const WebURL& url, const WTF::String& title) {
WTF::String markup("<img src=\"");
markup.append(EncodeWithURLEscapeSequences(url.GetString()));
markup.append(EscapeForHTML(url.GetString()));
markup.append("\"");
if (!title.IsEmpty()) {
markup.append(" alt=\"");
markup.append(EncodeWithURLEscapeSequences(title));
markup.append(EscapeForHTML(title));
markup.append("\"");
}
markup.append("/>");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment