@@ -5,6 +5,7 @@ require "rubygems"
55require "thor"
66require "open-uri"
77require "yaml"
8+ require "cgi"
89
910class 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
222228end
0 commit comments