Page MenuHomePhabricator

Hidetoc cookies should set path
Closed, ResolvedPublic

Description

I clicked the "hide" link on a Table Of Contents, then clicked "show" sometime later. However, my tables of contents are still getting hidden intermittently. I keep clicking "Show", which shows the TOC, but sometime later they are hidden again. Examining my cookies, I see FOUR cookies called "hidetoc", each with a different path. I'll bet this cookie is being set incorrectly, and that the problem is related to subpage URLs.

The cookies are:

Path = /wiki/
Content = 1

Path = /wiki/User:Danb/
Content = 1

Path = /wiki/User:Danb/status/
Content = 1

Path = /wiki/User:Danb/pitches/
Content = 0

This is on Firefox 3.6.13 on Windows 2008 Server.


Version: 1.16.x
Severity: minor

Details

Reference
bz26324

Related Objects

StatusSubtypeAssignedTask
ResolvedNone
ResolvedNone

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 11:22 PM
bzimport set Reference to bz26324.
bzimport added a subscriber: Unknown Object (MLST).

Sure it is. The toggleToc() code is doing just document.cookie = "hidetoc=1".
"If [path is] not specified, defaults to the current path of the current document location". so your assessment is right.

I think we should do instead:
document.cookie = 'hidetoc=7; path=' + escape( wgArticlePath.replace("$1", "") );

(note that I use escape because it leaves / untranslated but escapes ;, not sure if there may be any other dangerours characters)

During the rewrite of mediawiki.legacy (of which wikibits.js' toggleToc is a part of) this will be taken care off.

Adding to resourceloader tracking.

Fixed in r78941.

Cookie is now set domain wide instead of just the local path.

The bug that caused the TOC-setting to only apply to the current article or subpage - and being inconsistent depending on the view (ie. action=purge from scriptpath was different then viewing the same article from articlepath ("/w/"index.php?title=This vs. "/wiki/"This ) – is now fixed.

Should be live on translatewiki.net tomorrow.