The Shape of Everything
A website mostly about Mac stuff, written by August "Gus" Mueller
» Acorn
» Retrobatch
» Mastodon
» Instagram
» Github
» Maybe Pizza?
» Archives
» Feed
» Micro feed
November 19, 2003
(This post is from my old, old, super old site. My views have changed over the years, hopefully my writing has improved, and there is now more than a handful of folks reading my site. Enjoy.)

Well, I just fixed an "interesting" bug in VoodooPad.

A user had reported a bug, where a certain file he was dropping into VoodooPad to get linked up wasn't working right- an assertion failed, it threw up a dialog box saying so, and he hit the "autoreport" button and told me about it. A couple of emails and special VoodooPad builds back and forth and I figured out that it was a Jaguar problem- I was creating a NSURL via fileURLWithPath:, and later on calling [url path] on it to get back the original local path. But when I did that, it was throwing in an underscore (_20) for a space under "certain" conditions, and it was only doing it on Jaguar. Dagnebit! Silly 10.2!

So I booted into 10.2 and started to debug the problem in Project Builder, and ... hey- it's doing it for any files with spaces in the title... huh. It didn't do that before...

Flicker, flicker, pop. (That's the sound of the light-bulb going off again.)

I had recently created a category to NSString called "stringByAddingPercentEscapes". I added it for some new stuff in 1.1.1- and what it did was call CFURLCreateStringByAddingPercentEscapes, change all the spaces to _'s, and change the %'s into _'s, so people can upload html files they exported from VoodooPad without the webserver and/or ftp server freaking out a bit. Funny, that seems alot like what [NSURL path] was giving me... so I renamed it to fmStringByAddingPercentEscapes, and tada! The problem goes away.


The only thing I can think of that might have been causing this, is that there is an undocumented api in NSString called stringByAddingPercentEscapes in 10.2, and not in 10.3, and my category was intercepting those calls- and it just so happened that [NSURL path] calls it.

So from now on, I think I'll be prefixing all my category methods with Flying Meat. And eventually I'll even stop blaming the OS right away as well.