[Pkg-mozext-commits] [firebug] 09/56: Issue 7658 (Net panel misreports cookie expiration) https://code.google.com/p/fbug/issues/detail?id=7658

David Prévot taffit at moszumanska.debian.org
Wed Nov 19 21:01:41 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository firebug.

commit e1244fecd8fe1da13331cc376653136446215907
Author: Sebastian Zartner <sebastianzartner at gmail.com>
Date:   Mon Sep 15 13:27:13 2014 +0200

    Issue 7658 (Net panel misreports cookie expiration)
    https://code.google.com/p/fbug/issues/detail?id=7658
---
 extension/content/firebug/cookies/cookieUtils.js | 56 +++++++++++++++++-------
 1 file changed, 39 insertions(+), 17 deletions(-)

diff --git a/extension/content/firebug/cookies/cookieUtils.js b/extension/content/firebug/cookies/cookieUtils.js
index af1b525..e962e17 100644
--- a/extension/content/firebug/cookies/cookieUtils.js
+++ b/extension/content/firebug/cookies/cookieUtils.js
@@ -114,27 +114,11 @@ var CookieUtils =
                         break;
 
                     case "max-age":
-                        //Remove dash from variable name
                         cookie.maxAge = option[1];
                         break;
 
                     case "expires":
-                        var value = option[1];
-                        value = value.replace(/-/g, " ");
-                        cookie[name] = Date.parse(value) / 1000;
-
-                        // Log error if the date isn't correctly parsed.
-                        if (FBTrace.DBG_COOKIES)
-                        {
-                            var tempDate = new Date(cookie[name] * 1000);
-                            if (value != tempDate.toGMTString())
-                            {
-                                FBTrace.sysout("cookies.parseFromString: ERROR, " +
-                                    "from: " + value +
-                                    ", to: " + tempDate.toGMTString() +
-                                    ", cookie: " + string);
-                            }
-                        }
+                        cookie[name] = parseDate(option[1]);
                         break;
 
                     default:
@@ -143,6 +127,13 @@ var CookieUtils =
             }
         }
 
+        // If the expiration date and the max. age are not set for the cookie,
+        // it is a session cookie and therefore needs to be marked as such
+        // by setting the expiration date to 0
+        // (see issue 7658)
+        if (!cookie.hasOwnProperty("expires") && !cookie.hasOwnProperty("maxAge"))
+            cookie.expires = 0;
+
         return cookie;
     },
 
@@ -180,6 +171,37 @@ var CookieUtils =
 };
 
 // ********************************************************************************************* //
+// Helper functions
+
+function parseDate(dateString)
+{
+    // Date.parse() doesn't support the 2-digit year format and dashes,
+    // so reformat it appropriatly
+    // (see issue 7658)
+    dateString = dateString.replace(/(\d\d)(\s|-)([a-z]+|\d\d)\2(\d{2,4})/i, (...match) =>
+    {
+        return match[1] + " " + match[3] + " " +
+            (match[4].length === 2 ? "20" + match[4] : match[4]);
+    });
+
+    var date = Date.parse(dateString) / 1000;
+
+    // Log error if the date isn't correctly parsed.
+    if (FBTrace.DBG_COOKIES)
+    {
+        var tempDate = new Date(date * 1000);
+        if (dateString != tempDate.toGMTString())
+        {
+            FBTrace.sysout("CookieUtils.parseDate: ERROR, " +
+                "from: " + dateString +
+                ", to: " + tempDate.toGMTString());
+        }
+    }
+
+    return date;
+}
+
+// ********************************************************************************************* //
 
 return CookieUtils;
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/firebug.git



More information about the Pkg-mozext-commits mailing list