[M120 Migration] Limit the length and scheme of pageurl in favicon DB 68/310668/2
authorjiangyuwei <yuwei.jiang@samsung.com>
Mon, 6 May 2024 06:00:37 +0000 (14:00 +0800)
committerBot Blink <blinkbot@samsung.com>
Tue, 7 May 2024 20:36:39 +0000 (20:36 +0000)
The length of pageurl in favicon DB <= 1024.
The scheme of pageurl in favicon DB exclude data scheme.

References:
 - https://review.tizen.org/gerrit/304020/

Change-Id: I8d65da6df6836e19658213d3bb944192e955ce44
Signed-off-by: jiangyuwei <yuwei.jiang@samsung.com>
tizen_src/ewk/efl_integration/web_contents_observer_efl.cc

index a60d5af5ca7c556ebb73925132893db81cdfedc6..676bdd0e4bd14da87f422f5cafc13a1c10677e57 100644 (file)
@@ -42,6 +42,9 @@ using autofill::AutofillClientEfl;
 namespace content {
 
 namespace {
+
+const size_t kMaxPageURLLenForFaviconDatabase = 1024;
+
 typedef network::mojom::ContentSecurityPolicyType SecurityPolicyType;
 
 static_assert(static_cast<int>(SecurityPolicyType::kReport) ==
@@ -224,11 +227,14 @@ void WebContentsObserverEfl::DidUpdateFaviconURL(
 
     if (favicon->icon_type == blink::mojom::FaviconIconType::kFavicon) {
       NavigationEntry* entry = web_contents_.GetController().GetVisibleEntry();
-      if (!entry)
+      /* Limit the length(<= 1024) and scheme(exclude data scheme) of pageurl in
+       * favicon database */
+      if (!entry || entry->GetURL().SchemeIs(url::kDataScheme) ||
+          entry->GetURL().possibly_invalid_spec().length() >
+              kMaxPageURLLenForFaviconDatabase)
         return;
       entry->GetFavicon().url = favicon->icon_url;
       entry->GetFavicon().valid = true;
-
       // check/update the url and favicon url in favicon database
       FaviconDatabase::Instance()->SetFaviconURLForPageURL(favicon->icon_url,
                                                            entry->GetURL());