Closed Bug 670577 Opened 13 years ago Closed 4 years ago

Block exception cookies not allowed for local file:// files

Categories

(Core :: Networking: Cookies, defect, P5)

5 Branch
All
Other
defect

Tracking

()

RESOLVED INVALID

People

(Reporter: john, Unassigned)

References

Details

(Keywords: regression, Whiteboard: [necko-would-take])

User Agent: Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0
Build ID: 20110615151330

Steps to reproduce:

In FF 5.0 

1. Go to Tools > Options > Privacy.

2. Select "Use custom settings for history" from the History dropdown.

3. Untick "Accept cookies from sites".

4. Click Exceptions.

5. Allow all of the following in the "Address of web site" box

   a) file:///C:/index.html  - This should cause a c Site to appear with Allow Status
   b) local
   c) localhost

6. Save the following HTML and javascript to index.html (or another loocal file) and browse to the page. Reload the page in FF 5.0 (or perhaps any FF) a few times if you like.

<HTML>
<HEAD><TITLE>test</TITLE>
</HEAD>

<BODY>

<p>Cookie test<p>

<script>

var cookie = {}

cookie.set = function(name, value, expireDays) {
    var exdate=new Date(), cookie=name
    expireDays = expireDays || 0
    exdate.setDate(exdate.getDate() + expireDays)
    cookie += '=' + escape(value) 
    cookie += '; expires=' + (!expireDays ? 'Thu, 01-Jan-70 00:00:01 GMT' : exdate.toGMTString())
    document.cookie = cookie
}

cookie.get = function(name) {
    var start, end
    if (document.cookie.length > 0) {
        start=document.cookie.indexOf(name + "=")
        if (start!=-1) {
            start=start + name.length+1
            end=document.cookie.indexOf(";",start)
            if (end==-1) {
                end=document.cookie.length
            }
            return unescape(document.cookie.substring(start,end))
        }
    }
    return ""
}

cookie.enabled = function() {
    this.set('test', 'enabled', 1)
    if(this.get('test')) {
        this.set('test', '', 0) 
        return true
    }
    return false
}

alert( "Cookies are " + (cookie.enabled() ? "enabled" : "not enabled") )

</script>

</BODY>
</HTML>




Actual results:

Cookies are never enabled.


Expected results:

Cookies should be enabled, because we made an exception for local files. The exception didn't work. 

Please also note that if "Accept cookies from sites" is left ticked then cookies work ok. This also should show the script works OK.
Component: General → Networking: Cookies
Product: Firefox → Core
QA Contact: general → networking.cookies
Status: UNCONFIRMED → NEW
Ever confirmed: true
Bug 400097 broke this on purpose; see bug 400097 comment 9 (at least it removed the old code for scheme: on purpose; it's not clear that it necessarily intended to break all sorts of permissions for file:// behavior-wise).

See also bug 204285 comment 12 et seq, which is a similar bug to this but about pop-ups.

Not sure if cookies can be "fixed" locally in-app like pop-ups or not, but even if they can, it seems like there needs to be a separate bug filed against the Permissions Manager to restore some sane behavior for local files, perhaps as described in bug 204285 comment 34 et seq.
Blocks: 400097
Keywords: regression
I guess the issue likely comes from the CookiePermissionManager but I haven't looked more into it. If it is not the CookiePermissionManager, it comes from the UI given that the PermissionManager should now accept local files .
Whiteboard: [necko-would-take]
Bulk change to priority: https://bugzilla.mozilla.org/show_bug.cgi?id=1399258
Priority: -- → P5

This works fine after 7 years. Closing this bug as invalid.

Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.