Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6c7c110

Browse files
committed
Fixes issue #1 -- bundles with invalid URI characters cannot be downloaded
1 parent fe6a813 commit 6c7c110

3 files changed

Lines changed: 32 additions & 16 deletions

File tree

Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ require 'rake/gempackagetask'
33
require 'date'
44

55
GEM = "textmate"
6-
GEM_VERSION = "0.9.5"
6+
GEM_VERSION = "0.9.6"
77
AUTHOR = "Yehuda Katz"
88
99
HOMEPAGE = "http://yehudakatz.com"

bin/textmate

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ require "rubygems"
55
require "thor"
66
require "open-uri"
77
require "yaml"
8+
require "cgi"
89

910
class TextmateInstaller < Thor
1011

@@ -63,7 +64,7 @@ class TextmateInstaller < Thor
6364
when :git
6465
'echo "git remotes not implemented yet"'
6566
when :svn
66-
%[svn co #{e_sh location[:url]}/#{e_sh bundle_name}.tmbundle #{e_sh install_bundles_path}/#{e_sh bundle_name}.tmbundle 2>&1]
67+
%[svn co "#{location[:url]}/#{url_escape bundle_name}.tmbundle" #{e_sh install_bundles_path}/#{e_sh bundle_name}.tmbundle 2>&1]
6768
when :github
6869
repos = find_github_bundles(denormalize_github_repo_name(bundle_name))
6970

@@ -110,7 +111,7 @@ class TextmateInstaller < Thor
110111
desc "uninstall NAME", "uninstall a bundle"
111112
def uninstall(bundle_name)
112113
removed = false
113-
114+
114115
puts "Removing bundle..."
115116
# When moving to the trash, maybe move the bundle into a trash/disabled_bundles subfolder
116117
# named as the bundles_path key. Just in case there are multiple versions of
@@ -122,7 +123,7 @@ class TextmateInstaller < Thor
122123
%x[osascript -e 'tell application "Finder" to move the POSIX file "#{bundle_path}" to trash']
123124
end
124125
end
125-
126+
126127
unless removed
127128
say "There is no bundle by that name in the system", :red
128129
exit
@@ -175,6 +176,11 @@ class TextmateInstaller < Thor
175176
str.to_s.gsub(/(?=[^a-zA-Z0-9_.\/\-\x7F-\xFF\n])/, '\\').gsub(/\n/, "'\n'").sub(/^$/, "''")
176177
end
177178

179+
def url_escape(str)
180+
chars = ((33...47).to_a + (94...96).to_a + (123...126).to_a).map {|c| c.chr }.join + "\\[\\]\\\\"
181+
str = str.to_s.gsub(%r{[#{chars}]}) {|m| CGI.escape(m) }
182+
end
183+
178184
CAPITALIZATION_EXCEPTIONS = %w[tmbundle on]
179185
# Convert a GitHub repo name into a "normal" TM bundle name
180186
# e.g. ruby-on-rails-tmbundle => Ruby on Rails.tmbundle
@@ -207,16 +213,16 @@ class TextmateInstaller < Thor
207213

208214
def git_clone(repo, name)
209215
bundle_name = normalize_github_repo_name(name)
210-
216+
211217
path = "#{install_bundles_path}/#{bundle_name}"
212-
escaped_path = "#{e_sh install_bundles_path}/#{e_sh bundle_name}"
213-
218+
escaped_path = "#{e_sh(install_bundles_path)}/#{e_sh(bundle_name)}"
219+
214220
if File.directory?(path)
215221
say "Sorry, that bundle is already installed. Please uninstall it first.", :red
216222
exit
217223
end
218-
219-
%[git clone git://github.com/#{repo}/#{name}.git #{escaped_path} 2>&1]
224+
225+
%[git clone "git://github.com/#{url_escape(repo)}/#{url_escape(name)}.git" #{escaped_path} 2>&1]
220226
end
221227

222228
end

textmate.gemspec

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,34 @@
1+
# -*- encoding: utf-8 -*-
2+
13
Gem::Specification.new do |s|
24
s.name = %q{textmate}
3-
s.version = "0.9.3"
4-
5-
s.specification_version = 2 if s.respond_to? :specification_version=
5+
s.version = "0.9.6"
66

77
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
88
s.authors = ["Yehuda Katz"]
99
s.autorequire = %q{textmate}
10-
s.date = %q{2008-05-28}
10+
s.date = %q{2009-08-03}
1111
s.default_executable = %q{textmate}
1212
s.description = %q{Command-line textmate package manager}
1313
s.email = %q{[email protected]}
1414
s.executables = ["textmate"]
1515
s.extra_rdoc_files = ["README.markdown", "LICENSE"]
1616
s.files = ["LICENSE", "README.markdown", "Rakefile", "bin/textmate"]
17-
s.has_rdoc = true
1817
s.homepage = %q{http://yehudakatz.com}
1918
s.require_paths = ["bin"]
20-
s.rubygems_version >= %q{1.1.1}
19+
s.rubygems_version = %q{1.3.5}
2120
s.summary = %q{Command-line textmate package manager}
2221

23-
s.add_dependency(%q<thor>, [">= 0.9.2"])
22+
if s.respond_to? :specification_version then
23+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
24+
s.specification_version = 3
25+
26+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
27+
s.add_runtime_dependency(%q<thor>, [">= 0.9.2"])
28+
else
29+
s.add_dependency(%q<thor>, [">= 0.9.2"])
30+
end
31+
else
32+
s.add_dependency(%q<thor>, [">= 0.9.2"])
33+
end
2434
end

0 commit comments

Comments
 (0)