| 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..1bcf6a6a97d9db858175b36879d02342b66f1d84 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=(%04d)%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().ascii();
|
| + 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);
|
| + }
|
| + CString escapedUrl = builder.toString().ascii();
|
| + return String::format("saved from url=(%04d)%s", static_cast<int>(escapedUrl.length()), escapedUrl.data());
|
| +}
|
| +
|
| } // namespace blink
|
|
|