merged Allow a cookie without a domain to be set on Android
This commit is contained in:
parent
b603ea275f
commit
45ef5c3755
|
@ -42,6 +42,7 @@
|
||||||
- Merged "fix: Prevent Android java.lang.NullPointerException in InAppWebViewCl…" [#1237](https://github.com/pichillilorenzo/flutter_inappwebview/pull/1237) (thanks to [kamilpowalowski](https://github.com/kamilpowalowski))
|
- Merged "fix: Prevent Android java.lang.NullPointerException in InAppWebViewCl…" [#1237](https://github.com/pichillilorenzo/flutter_inappwebview/pull/1237) (thanks to [kamilpowalowski](https://github.com/kamilpowalowski))
|
||||||
- Merged "Android - Load client certificate from local storage" [#1241](https://github.com/pichillilorenzo/flutter_inappwebview/pull/1241) (thanks to [akioyamamoto1977](https://github.com/akioyamamoto1977))
|
- Merged "Android - Load client certificate from local storage" [#1241](https://github.com/pichillilorenzo/flutter_inappwebview/pull/1241) (thanks to [akioyamamoto1977](https://github.com/akioyamamoto1977))
|
||||||
- Merged "fix Theme_AppCompat_Dialog_Alert not found" [#1262](https://github.com/pichillilorenzo/flutter_inappwebview/pull/1262) (thanks to [mohenaxiba](https://github.com/mohenaxiba))
|
- Merged "fix Theme_AppCompat_Dialog_Alert not found" [#1262](https://github.com/pichillilorenzo/flutter_inappwebview/pull/1262) (thanks to [mohenaxiba](https://github.com/mohenaxiba))
|
||||||
|
- Merged "Allow a cookie without a domain to be set on Android" [#1295](https://github.com/pichillilorenzo/flutter_inappwebview/pull/1295) (thanks to [bagedevimo](https://github.com/bagedevimo))
|
||||||
|
|
||||||
## 5.4.4+3
|
## 5.4.4+3
|
||||||
|
|
||||||
|
|
|
@ -141,7 +141,10 @@ public class MyCookieManager extends ChannelDelegateImpl {
|
||||||
cookieManager = getCookieManager();
|
cookieManager = getCookieManager();
|
||||||
if (cookieManager == null) return;
|
if (cookieManager == null) return;
|
||||||
|
|
||||||
String cookieValue = name + "=" + value + "; Domain=" + domain + "; Path=" + path;
|
String cookieValue = name + "=" + value + "; Path=" + path;
|
||||||
|
|
||||||
|
if (domain != null)
|
||||||
|
cookieValue += "; Domain=" + domain;
|
||||||
|
|
||||||
if (expiresDate != null)
|
if (expiresDate != null)
|
||||||
cookieValue += "; Expires=" + getCookieExpirationDate(expiresDate);
|
cookieValue += "; Expires=" + getCookieExpirationDate(expiresDate);
|
||||||
|
|
|
@ -27,7 +27,6 @@ public class MyCookieManager: ChannelDelegate {
|
||||||
let url = arguments!["url"] as! String
|
let url = arguments!["url"] as! String
|
||||||
let name = arguments!["name"] as! String
|
let name = arguments!["name"] as! String
|
||||||
let value = arguments!["value"] as! String
|
let value = arguments!["value"] as! String
|
||||||
let domain = arguments!["domain"] as! String
|
|
||||||
let path = arguments!["path"] as! String
|
let path = arguments!["path"] as! String
|
||||||
|
|
||||||
var expiresDate: Int64?
|
var expiresDate: Int64?
|
||||||
|
@ -39,12 +38,13 @@ public class MyCookieManager: ChannelDelegate {
|
||||||
let isSecure = arguments!["isSecure"] as? Bool
|
let isSecure = arguments!["isSecure"] as? Bool
|
||||||
let isHttpOnly = arguments!["isHttpOnly"] as? Bool
|
let isHttpOnly = arguments!["isHttpOnly"] as? Bool
|
||||||
let sameSite = arguments!["sameSite"] as? String
|
let sameSite = arguments!["sameSite"] as? String
|
||||||
|
let domain = arguments!["domain"] as? String
|
||||||
|
|
||||||
MyCookieManager.setCookie(url: url,
|
MyCookieManager.setCookie(url: url,
|
||||||
name: name,
|
name: name,
|
||||||
value: value,
|
value: value,
|
||||||
domain: domain,
|
|
||||||
path: path,
|
path: path,
|
||||||
|
domain: domain,
|
||||||
expiresDate: expiresDate,
|
expiresDate: expiresDate,
|
||||||
maxAge: maxAge,
|
maxAge: maxAge,
|
||||||
isSecure: isSecure,
|
isSecure: isSecure,
|
||||||
|
@ -84,8 +84,8 @@ public class MyCookieManager: ChannelDelegate {
|
||||||
public static func setCookie(url: String,
|
public static func setCookie(url: String,
|
||||||
name: String,
|
name: String,
|
||||||
value: String,
|
value: String,
|
||||||
domain: String,
|
|
||||||
path: String,
|
path: String,
|
||||||
|
domain: String?,
|
||||||
expiresDate: Int64?,
|
expiresDate: Int64?,
|
||||||
maxAge: Int64?,
|
maxAge: Int64?,
|
||||||
isSecure: Bool?,
|
isSecure: Bool?,
|
||||||
|
@ -101,8 +101,12 @@ public class MyCookieManager: ChannelDelegate {
|
||||||
properties[.originURL] = url
|
properties[.originURL] = url
|
||||||
properties[.name] = name
|
properties[.name] = name
|
||||||
properties[.value] = value
|
properties[.value] = value
|
||||||
properties[.domain] = domain
|
|
||||||
properties[.path] = path
|
properties[.path] = path
|
||||||
|
|
||||||
|
if domain != nil {
|
||||||
|
properties[.domain] = domain
|
||||||
|
}
|
||||||
|
|
||||||
if expiresDate != nil {
|
if expiresDate != nil {
|
||||||
// convert from milliseconds
|
// convert from milliseconds
|
||||||
properties[.expires] = Date(timeIntervalSince1970: TimeInterval(Double(expiresDate!)/1000))
|
properties[.expires] = Date(timeIntervalSince1970: TimeInterval(Double(expiresDate!)/1000))
|
||||||
|
|
|
@ -58,7 +58,6 @@ class CookieManager {
|
||||||
///The cookie being set will be ignored if it is expired.
|
///The cookie being set will be ignored if it is expired.
|
||||||
///
|
///
|
||||||
///The default value of [path] is `"/"`.
|
///The default value of [path] is `"/"`.
|
||||||
///If [domain] is `null`, its default value will be the domain name of [url].
|
|
||||||
///
|
///
|
||||||
///[webViewController] could be used if you need to set a session-only cookie using JavaScript (so [isHttpOnly] cannot be set, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies)
|
///[webViewController] could be used if you need to set a session-only cookie using JavaScript (so [isHttpOnly] cannot be set, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies)
|
||||||
///on the current URL of the [WebView] managed by that controller when you need to target iOS below 11 and Web platform. In this case the [url] parameter is ignored.
|
///on the current URL of the [WebView] managed by that controller when you need to target iOS below 11 and Web platform. In this case the [url] parameter is ignored.
|
||||||
|
@ -78,8 +77,8 @@ class CookieManager {
|
||||||
{required Uri url,
|
{required Uri url,
|
||||||
required String name,
|
required String name,
|
||||||
required String value,
|
required String value,
|
||||||
String? domain,
|
|
||||||
String path = "/",
|
String path = "/",
|
||||||
|
String? domain,
|
||||||
int? expiresDate,
|
int? expiresDate,
|
||||||
int? maxAge,
|
int? maxAge,
|
||||||
bool? isSecure,
|
bool? isSecure,
|
||||||
|
@ -88,14 +87,12 @@ class CookieManager {
|
||||||
@Deprecated("Use webViewController instead")
|
@Deprecated("Use webViewController instead")
|
||||||
InAppWebViewController? iosBelow11WebViewController,
|
InAppWebViewController? iosBelow11WebViewController,
|
||||||
InAppWebViewController? webViewController}) async {
|
InAppWebViewController? webViewController}) async {
|
||||||
if (domain == null) domain = _getDomainName(url);
|
|
||||||
|
|
||||||
webViewController = webViewController ?? iosBelow11WebViewController;
|
webViewController = webViewController ?? iosBelow11WebViewController;
|
||||||
|
|
||||||
assert(url.toString().isNotEmpty);
|
assert(url.toString().isNotEmpty);
|
||||||
assert(name.isNotEmpty);
|
assert(name.isNotEmpty);
|
||||||
assert(value.isNotEmpty);
|
assert(value.isNotEmpty);
|
||||||
assert(domain.isNotEmpty);
|
|
||||||
assert(path.isNotEmpty);
|
assert(path.isNotEmpty);
|
||||||
|
|
||||||
if (defaultTargetPlatform == TargetPlatform.iOS || kIsWeb) {
|
if (defaultTargetPlatform == TargetPlatform.iOS || kIsWeb) {
|
||||||
|
@ -140,15 +137,16 @@ class CookieManager {
|
||||||
{required Uri url,
|
{required Uri url,
|
||||||
required String name,
|
required String name,
|
||||||
required String value,
|
required String value,
|
||||||
required String domain,
|
|
||||||
String path = "/",
|
String path = "/",
|
||||||
|
String? domain,
|
||||||
int? expiresDate,
|
int? expiresDate,
|
||||||
int? maxAge,
|
int? maxAge,
|
||||||
bool? isSecure,
|
bool? isSecure,
|
||||||
HTTPCookieSameSitePolicy? sameSite,
|
HTTPCookieSameSitePolicy? sameSite,
|
||||||
InAppWebViewController? webViewController}) async {
|
InAppWebViewController? webViewController}) async {
|
||||||
var cookieValue =
|
var cookieValue = name + "=" + value + "; Path=" + path;
|
||||||
name + "=" + value + "; Domain=" + domain + "; Path=" + path;
|
|
||||||
|
if (domain != null) cookieValue += "; Domain=" + domain;
|
||||||
|
|
||||||
if (expiresDate != null)
|
if (expiresDate != null)
|
||||||
cookieValue += "; Expires=" + await _getCookieExpirationDate(expiresDate);
|
cookieValue += "; Expires=" + await _getCookieExpirationDate(expiresDate);
|
||||||
|
|
Loading…
Reference in New Issue