Permalink
Browse files

Fixes issue #1 -- bundles with invalid URI characters cannot be downl…

…oaded
  • Loading branch information...
1 parent fe6a813 commit 6c7c1101994fe6faf409d6b794a06c987f2c95b3 @wycats committed Aug 3, 2009
Showing with 32 additions and 16 deletions.
  1. +1 −1 Rakefile
  2. +14 −8 bin/textmate
  3. +17 −7 textmate.gemspec
View
@@ -3,7 +3,7 @@ require 'rake/gempackagetask'
require 'date'
GEM = "textmate"
-GEM_VERSION = "0.9.5"
+GEM_VERSION = "0.9.6"
AUTHOR = "Yehuda Katz"
EMAIL = "wycats@gmail.com"
HOMEPAGE = "http://yehudakatz.com"
View
@@ -5,6 +5,7 @@ require "rubygems"
require "thor"
require "open-uri"
require "yaml"
+require "cgi"
class TextmateInstaller < Thor
@@ -63,7 +64,7 @@ class TextmateInstaller < Thor
when :git
'echo "git remotes not implemented yet"'
when :svn
- %[svn co #{e_sh location[:url]}/#{e_sh bundle_name}.tmbundle #{e_sh install_bundles_path}/#{e_sh bundle_name}.tmbundle 2>&1]
+ %[svn co "#{location[:url]}/#{url_escape bundle_name}.tmbundle" #{e_sh install_bundles_path}/#{e_sh bundle_name}.tmbundle 2>&1]
when :github
repos = find_github_bundles(denormalize_github_repo_name(bundle_name))
@@ -110,7 +111,7 @@ class TextmateInstaller < Thor
desc "uninstall NAME", "uninstall a bundle"
def uninstall(bundle_name)
removed = false
-
+
puts "Removing bundle..."
# When moving to the trash, maybe move the bundle into a trash/disabled_bundles subfolder
# named as the bundles_path key. Just in case there are multiple versions of
@@ -122,7 +123,7 @@ class TextmateInstaller < Thor
%x[osascript -e 'tell application "Finder" to move the POSIX file "#{bundle_path}" to trash']
end
end
-
+
unless removed
say "There is no bundle by that name in the system", :red
exit
@@ -175,6 +176,11 @@ class TextmateInstaller < Thor
str.to_s.gsub(/(?=[^a-zA-Z0-9_.\/\-\x7F-\xFF\n])/, '\\').gsub(/\n/, "'\n'").sub(/^$/, "''")
end
+ def url_escape(str)
+ chars = ((33...47).to_a + (94...96).to_a + (123...126).to_a).map {|c| c.chr }.join + "\\[\\]\\\\"
+ str = str.to_s.gsub(%r{[#{chars}]}) {|m| CGI.escape(m) }
+ end
+
CAPITALIZATION_EXCEPTIONS = %w[tmbundle on]
# Convert a GitHub repo name into a "normal" TM bundle name
# e.g. ruby-on-rails-tmbundle => Ruby on Rails.tmbundle
@@ -207,16 +213,16 @@ class TextmateInstaller < Thor
def git_clone(repo, name)
bundle_name = normalize_github_repo_name(name)
-
+
path = "#{install_bundles_path}/#{bundle_name}"
- escaped_path = "#{e_sh install_bundles_path}/#{e_sh bundle_name}"
-
+ escaped_path = "#{e_sh(install_bundles_path)}/#{e_sh(bundle_name)}"
+
if File.directory?(path)
say "Sorry, that bundle is already installed. Please uninstall it first.", :red
exit
end
-
- %[git clone git://github.com/#{repo}/#{name}.git #{escaped_path} 2>&1]
+
+ %[git clone "git://github.com/#{url_escape(repo)}/#{url_escape(name)}.git" #{escaped_path} 2>&1]
end
end
View
@@ -1,24 +1,34 @@
+# -*- encoding: utf-8 -*-
+
Gem::Specification.new do |s|
s.name = %q{textmate}
- s.version = "0.9.3"
-
- s.specification_version = 2 if s.respond_to? :specification_version=
+ s.version = "0.9.6"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Yehuda Katz"]
s.autorequire = %q{textmate}
- s.date = %q{2008-05-28}
+ s.date = %q{2009-08-03}
s.default_executable = %q{textmate}
s.description = %q{Command-line textmate package manager}
s.email = %q{wycats@gmail.com}
s.executables = ["textmate"]
s.extra_rdoc_files = ["README.markdown", "LICENSE"]
s.files = ["LICENSE", "README.markdown", "Rakefile", "bin/textmate"]
- s.has_rdoc = true
s.homepage = %q{http://yehudakatz.com}
s.require_paths = ["bin"]
- s.rubygems_version >= %q{1.1.1}
+ s.rubygems_version = %q{1.3.5}
s.summary = %q{Command-line textmate package manager}
- s.add_dependency(%q<thor>, [">= 0.9.2"])
+ if s.respond_to? :specification_version then
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
+ s.specification_version = 3
+
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
+ s.add_runtime_dependency(%q<thor>, [">= 0.9.2"])
+ else
+ s.add_dependency(%q<thor>, [">= 0.9.2"])
+ end
+ else
+ s.add_dependency(%q<thor>, [">= 0.9.2"])
+ end
end

0 comments on commit 6c7c110

Please sign in to comment.