today | current | recent | random ... categories | search ... who ... syndication

Movable Thoughts #19 : CGIPath != mod_dir.c

A "trailing slash" redirect is issued when the server receives a request for a URL http://servername/foo/dirname where dirname is a directory. Directories require a trailing slash, so mod_dir issues a redirect to http://servername/foo/dirname/.

I upgraded a copy of Movable Type to 2.64 the other day and, of course, it broke. Specifically the cookies that the program tries to set didn't seem to stick. Every time I tried to do anything I would be taken back to the login page. Well it's been a while since I've poked around MT, I thought, so I will suffer the MT support site that I hate so much (why do I need to log in just to search the bloody thing?!) and see if it's a known bug. Sure enough, there are no shortage of Dude, where's my cookie? style messages. Unfortunately, the only thing anyone seems to be saying in response is : Dude, just delete your cookies! Sure, thanks Wonder Bread. Anyway, eventually it dawned on me to actually look at the cookie and I discovered that the Path field contains a fully formed URI. Which explains why the cookies are failing but not why they're being set incorrectly. Line 374 of MT::App.pm reads :



 if ($path =~ m!^https?://[^/]+(/.*)$!i) {



where $1 (the first set of matching brackets : that would be everything after the first forward slash following the standard URI [insert protocol here]:// stuff) is assigned as your cookie's Path. Which means that unless your Movable Type CGIPath config variable contains a trailing slash, the program will seriously bork your cookies. DWIM-ing and user-centric idiot-proofing aside, I am inclined to think that this is a documentation bug rather than a problem with the code. Apache happens to do "trailing slash" redirects out of the box which is nice but probably not reason enough to expect every other web programmer to do the same thing. Now you know.

refers to

meta

 
Ponie is a version of Perl 5 that will run on Parrot. ←  → Douglas McLennan : "It's not particularly in their interest to cut us off. I can be their biggest deliverer of traffic."