From d498dc5f130c266c5f533e1edad73fd41948037d Mon Sep 17 00:00:00 2001 From: Deven Speyrer <52427202+dspeyrer@users.noreply.github.com> Date: Tue, 19 Apr 2022 20:18:29 -0600 Subject: [PATCH 1/2] Make the Netscape cookie export function properly Appends "# Netscape HTTP Cookie File" to the beginning of the file, and uppercases booleans in the export. --- src/api.js | 2 +- src/export.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/api.js b/src/api.js index 7de6d40..e4b9e04 100644 --- a/src/api.js +++ b/src/api.js @@ -790,7 +790,7 @@ vAPI.template_JSON = { vAPI.template_Netscape = { name: 'NETSCAPE', template: '{DOMAIN_RAW}\t{ISDOMAIN_RAW}\t{PATH_RAW}\t{ISSECURE_RAW}\t{EXPIRES_RAW}\t{NAME_RAW}\t{CONTENT_RAW}', - left_tag: '', + left_tag: '# Netscape HTTP Cookie File\n\n', right_tag: '', separator: '\n', }; diff --git a/src/export.js b/src/export.js index 26af137..0d7efbb 100644 --- a/src/export.js +++ b/src/export.js @@ -292,11 +292,11 @@ function build_domain_dump(cookie) { '{EXPIRES}': get_timestamp(false), '{EXPIRES_RAW}': get_timestamp(true), '{ISSECURE}': get_secure_status(false), - '{ISSECURE_RAW}': get_secure_status(true), + '{ISSECURE_RAW}': get_secure_status(true).toString().toUpperCase(), '{ISHTTPONLY_RAW}': cookie.httpOnly, '{SAMESITE_RAW}': cookie.sameSite ? cookie.sameSite : "no_restriction", '{ISDOMAIN}': get_domain_status(false), - '{ISDOMAIN_RAW}': cookie.hostOnly, + '{ISDOMAIN_RAW}': cookie.hostOnly.toString().toUpperCase(), '{STORE_RAW}': cookie.storeId, '{FPI_RAW}': cookie.firstPartyDomain ? cookie.firstPartyDomain : "", // This attr is absent on old FF }; From 7ab18e0b6f7355c1b56417a2ac93208c8128f946 Mon Sep 17 00:00:00 2001 From: Deven Speyrer Date: Tue, 19 Apr 2022 20:35:09 -0600 Subject: [PATCH 2/2] Make sure original format is retained for JSON exports Changed to only capitalize the boolean raw values if the template is 'NETSCAPE'. --- src/export.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/export.js b/src/export.js index 0d7efbb..0560b0e 100644 --- a/src/export.js +++ b/src/export.js @@ -283,6 +283,8 @@ function build_domain_dump(cookie) { // Make a local copy of the template var template_temp = cookie_clipboard_template.template; + var isNetscape = cookie_clipboard_template.name == 'NETSCAPE'; + var params = { '{HOST_RAW}': vAPI.getHostUrl(cookie), '{DOMAIN_RAW}': cookie.domain, @@ -292,11 +294,11 @@ function build_domain_dump(cookie) { '{EXPIRES}': get_timestamp(false), '{EXPIRES_RAW}': get_timestamp(true), '{ISSECURE}': get_secure_status(false), - '{ISSECURE_RAW}': get_secure_status(true).toString().toUpperCase(), - '{ISHTTPONLY_RAW}': cookie.httpOnly, + '{ISSECURE_RAW}': isNetscape ? get_secure_status(true).toString().toUpperCase() : get_secure_status(true), + '{ISHTTPONLY_RAW}': isNetscape ? cookie.httpOnly.toString().toUpperCase() : cookie.httpOnly, '{SAMESITE_RAW}': cookie.sameSite ? cookie.sameSite : "no_restriction", '{ISDOMAIN}': get_domain_status(false), - '{ISDOMAIN_RAW}': cookie.hostOnly.toString().toUpperCase(), + '{ISDOMAIN_RAW}': isNetscape ? cookie.hostOnly.toString().toUpperCase() : cookie.hostOnly, '{STORE_RAW}': cookie.storeId, '{FPI_RAW}': cookie.firstPartyDomain ? cookie.firstPartyDomain : "", // This attr is absent on old FF };