Chromium Code Reviews| Index: third_party/WebKit/Source/core/page/PageSerializer.cpp |
| diff --git a/third_party/WebKit/Source/core/page/PageSerializer.cpp b/third_party/WebKit/Source/core/page/PageSerializer.cpp |
| index 96d4a4220cefb9f71e00401f2d79b9e7dd80b2b3..c41f552a0e6dd0085f231a2303818ee8dd06bc7b 100644 |
| --- a/third_party/WebKit/Source/core/page/PageSerializer.cpp |
| +++ b/third_party/WebKit/Source/core/page/PageSerializer.cpp |
| @@ -253,9 +253,7 @@ void LinkChangeSerializerMarkupAccumulator::appendElement(StringBuilder& result, |
| // Add MOTW (Mark of the Web) declaration before html tag. |
| // See http://msdn2.microsoft.com/en-us/library/ms537628(VS.85).aspx. |
| result.append('\n'); |
| - MarkupFormatter::appendComment(result, String::format(" saved from url=(%04d)%s ", |
| - static_cast<int>(document().url().string().utf8().length()), |
| - document().url().string().utf8().data())); |
| + MarkupFormatter::appendComment(result, PageSerializer::markOfTheWebDeclaration(document().url())); |
| result.append('\n'); |
| } |
| @@ -577,4 +575,26 @@ PageSerializer::Delegate* PageSerializer::delegate() |
| return m_delegate.get(); |
| } |
| +// Returns MOTW (Mark of the Web) declaration before html tag which is in |
| +// HTML comment, e.g. "<!-- saved from url=(%04zu)%s -->" |
| +// See http://msdn2.microsoft.com/en-us/library/ms537628(VS.85).aspx. |
| +String PageSerializer::markOfTheWebDeclaration(const KURL& url) |
| +{ |
| + StringBuilder builder; |
| + bool emitsMinus = false; |
| + CString orignalUrl = url.string().utf8(); |
| + for (const char* string = orignalUrl.data(); *string; ++string) { |
| + const char ch = *string; |
| + if (ch == '-' && emitsMinus) { |
| + builder.append("%2D"); |
| + emitsMinus = false; |
| + continue; |
| + } |
| + emitsMinus = ch == '-'; |
| + builder.append(ch); |
|
tkent
2015/09/30 09:01:46
This line adds a part of UTF8-encoded Unicode char
yosin_UTC9
2015/09/30 10:14:59
No. |url| should be ASCII characters.
I changed |u
|
| + } |
| + CString escapedUrl = builder.toString().utf8(); |
| + return String::format("saved from url=(%04zu)%s", escapedUrl.length(), escapedUrl.data()); |
|
yosin_UTC9
2015/09/30 10:14:59
It seems Windows doesn't like %04zu. I'll use %04d
|
| +} |
| + |
| } // namespace blink |