From d92bb6c4e1d0edadcb7c45c36b5fefcb2d484330 Mon Sep 17 00:00:00 2001 From: lai Date: Tue, 31 Dec 2024 16:07:47 +0800 Subject: [PATCH] fix #2484, Remove not-empty assert for Cookie.value --- .../cookie_manager/set_get_delete.dart | 10 +++++++++- .../lib/src/cookie_manager.dart | 1 - flutter_inappwebview_ios/lib/src/cookie_manager.dart | 1 - flutter_inappwebview_macos/lib/src/cookie_manager.dart | 1 - flutter_inappwebview_web/lib/src/cookie_manager.dart | 1 - .../lib/src/cookie_manager.dart | 1 - 6 files changed, 9 insertions(+), 6 deletions(-) diff --git a/flutter_inappwebview/example/integration_test/cookie_manager/set_get_delete.dart b/flutter_inappwebview/example/integration_test/cookie_manager/set_get_delete.dart index 4c6d04d2b..13f637793 100644 --- a/flutter_inappwebview/example/integration_test/cookie_manager/set_get_delete.dart +++ b/flutter_inappwebview/example/integration_test/cookie_manager/set_get_delete.dart @@ -55,11 +55,19 @@ void setGetDelete() { expect(await cookieManager.removeSessionCookies(), isTrue); } - await cookieManager.setCookie(url: url, name: "myCookie", value: "myValue"); + // Empty cookie-value is allowed according to https://datatracker.ietf.org/doc/html/rfc6265#section-4.1.1 + await cookieManager.setCookie(url: url, name: "myCookie", value: ""); List cookies = await cookieManager.getCookies(url: url); expect(cookies, isNotEmpty); Cookie? cookie = await cookieManager.getCookie(url: url, name: "myCookie"); + expect(cookie?.value.toString(), ""); + + await cookieManager.setCookie(url: url, name: "myCookie", value: "myValue"); + cookies = await cookieManager.getCookies(url: url); + expect(cookies, isNotEmpty); + + cookie = await cookieManager.getCookie(url: url, name: "myCookie"); expect(cookie?.value.toString(), "myValue"); expect( diff --git a/flutter_inappwebview_android/lib/src/cookie_manager.dart b/flutter_inappwebview_android/lib/src/cookie_manager.dart index 86ae5fe81..af6dc9a5e 100755 --- a/flutter_inappwebview_android/lib/src/cookie_manager.dart +++ b/flutter_inappwebview_android/lib/src/cookie_manager.dart @@ -76,7 +76,6 @@ class AndroidCookieManager extends PlatformCookieManager PlatformInAppWebViewController? webViewController}) async { assert(url.toString().isNotEmpty); assert(name.isNotEmpty); - assert(value.isNotEmpty); assert(path.isNotEmpty); Map args = {}; diff --git a/flutter_inappwebview_ios/lib/src/cookie_manager.dart b/flutter_inappwebview_ios/lib/src/cookie_manager.dart index 2c0eea9cd..faad567c6 100755 --- a/flutter_inappwebview_ios/lib/src/cookie_manager.dart +++ b/flutter_inappwebview_ios/lib/src/cookie_manager.dart @@ -80,7 +80,6 @@ class IOSCookieManager extends PlatformCookieManager with ChannelController { assert(url.toString().isNotEmpty); assert(name.isNotEmpty); - assert(value.isNotEmpty); assert(path.isNotEmpty); if (await _shouldUseJavascript()) { diff --git a/flutter_inappwebview_macos/lib/src/cookie_manager.dart b/flutter_inappwebview_macos/lib/src/cookie_manager.dart index 6078cb526..ecfd306de 100755 --- a/flutter_inappwebview_macos/lib/src/cookie_manager.dart +++ b/flutter_inappwebview_macos/lib/src/cookie_manager.dart @@ -80,7 +80,6 @@ class MacOSCookieManager extends PlatformCookieManager with ChannelController { assert(url.toString().isNotEmpty); assert(name.isNotEmpty); - assert(value.isNotEmpty); assert(path.isNotEmpty); if (await _shouldUseJavascript()) { diff --git a/flutter_inappwebview_web/lib/src/cookie_manager.dart b/flutter_inappwebview_web/lib/src/cookie_manager.dart index a173b471e..7686f7699 100755 --- a/flutter_inappwebview_web/lib/src/cookie_manager.dart +++ b/flutter_inappwebview_web/lib/src/cookie_manager.dart @@ -81,7 +81,6 @@ class WebPlatformCookieManager extends PlatformCookieManager assert(url.toString().isNotEmpty); assert(name.isNotEmpty); - assert(value.isNotEmpty); assert(path.isNotEmpty); await _setCookieWithJavaScript( diff --git a/flutter_inappwebview_windows/lib/src/cookie_manager.dart b/flutter_inappwebview_windows/lib/src/cookie_manager.dart index f77c3bf49..386082d03 100644 --- a/flutter_inappwebview_windows/lib/src/cookie_manager.dart +++ b/flutter_inappwebview_windows/lib/src/cookie_manager.dart @@ -89,7 +89,6 @@ class WindowsCookieManager extends PlatformCookieManager PlatformInAppWebViewController? webViewController}) async { assert(url.toString().isNotEmpty); assert(name.isNotEmpty); - assert(value.isNotEmpty); assert(path.isNotEmpty); Map args = {};