From 73057062944075d82563ab3ecd0c73b63ede2b2d Mon Sep 17 00:00:00 2001 From: Le Tan Date: Tue, 3 Jul 2018 19:35:17 +0800 Subject: [PATCH] export: escape ' by %27 in data URI --- src/utils/vwebutils.cpp | 4 ++++ src/utils/vwebutils.h | 1 + 2 files changed, 5 insertions(+) diff --git a/src/utils/vwebutils.cpp b/src/utils/vwebutils.cpp index e0235b0f..49a0cc92 100644 --- a/src/utils/vwebutils.cpp +++ b/src/utils/vwebutils.cpp @@ -926,6 +926,7 @@ QString VWebUtils::copyResource(const QUrl &p_url, const QString &p_folder) cons return succ ? targetFile : QString(); } +// Please use single quote to quote the URI. QString VWebUtils::dataURI(const QUrl &p_url, bool p_keepTitle) const { QString uri; @@ -961,6 +962,9 @@ QString VWebUtils::dataURI(const QUrl &p_url, bool p_keepTitle) const // will be removed in M68, around July 2018. Please use '%23' instead. uri.replace("#", "%23"); + // Escape "'" to avoid conflict with src='...' attribute. + uri.replace("'", "%27"); + if (!p_keepTitle) { // Remove .... QRegExp reg(".*", Qt::CaseInsensitive); diff --git a/src/utils/vwebutils.h b/src/utils/vwebutils.h index 4d446951..4ee9465a 100644 --- a/src/utils/vwebutils.h +++ b/src/utils/vwebutils.h @@ -26,6 +26,7 @@ public: QString copyResource(const QUrl &p_url, const QString &p_folder) const; // Return a dataURI of @p_url if it is an image. + // Please use single quote to quote the URI. QString dataURI(const QUrl &p_url, bool p_keepTitle = true) const; private: