andymatuschak/TestMigration — Issue #80: Correctly escaped URLs are corrupted
Author: andymatuschak
Created: 2011-10-23 16:44:08+00:00
State: open
Labels: Migrated

***Chris (chris0)** [reported (on Launchpad)](https://bugs.launchpad.net/sparkle/+bug/654366) on' 2010-10-04:*

I've been using an older version of Sparkle (v1.1 I believe), but this
problem appears to still exist in the latest revision.

If the RSS feed file contains a (correctly escaped) URL such as
"http://any.com/name%20with%20spaces" then the file will fail to
download.

The culprit is here:
File: SUAppcastItem.m
Line: 141
[self setFileURL:[NSURL URLWithString:[[enclosure objectForKey:@"url"] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];

To continue to provide support for (bad) incorrectly escaped URLs you
could simply invoke 'stringByReplacingPercentEscapesUsingEncoding:'
immediately prior to 'stringByAddingPercentEscapesUsingEncoding:'.

So line 141 would then be:
[self setFileURL: [NSURL URLWithString: [[[enclosure objectForKey: @"url"] stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding] stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]]];