Skip to content
This repository

bundler root path should be escaped #1789

Merged
merged 1 commit into from about 2 years ago

3 participants

Aaron Patterson André Arko Erik Michaels-Ober
Aaron Patterson
Collaborator

I don't know how to write a test for this, but if you create a rails application under a directory that has regular expression characters in it, bundler will break.

Unfortunately, a fatal error has occurred. Please report this error to the Bundler issue tracker at https://github.com/carlhuda/bundler/issues so that we can fix it. Please include the full output of the command, your Gemfile and Gemfile.lock. Thanks!
/Users/aaron/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.1/lib/bundler/source.rb:422:in `relative_path': empty char-class: /^\/Users\/aaron\/git\/foo[]bar\/lolwut/ (RegexpError)
    from /Users/aaron/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.1/lib/bundler/source.rb:308:in `to_lock'
    from /Users/aaron/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.1/lib/bundler/definition.rb:254:in `block in to_lock'
    from /Users/aaron/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.1/lib/bundler/definition.rb:252:in `each'
    from /Users/aaron/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.1/lib/bundler/definition.rb:252:in `to_lock'
    from /Users/aaron/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.1/lib/bundler/definition.rb:233:in `lock'
    from /Users/aaron/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.1/lib/bundler/environment.rb:39:in `lock'
    from /Users/aaron/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.1/lib/bundler/installer.rb:59:in `run'
    from /Users/aaron/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.1/lib/bundler/installer.rb:12:in `install'
    from /Users/aaron/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.1/lib/bundler/cli.rb:220:in `install'
    from /Users/aaron/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.1/lib/bundler/vendor/thor/task.rb:22:in `run'
    from /Users/aaron/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.1/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
    from /Users/aaron/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.1/lib/bundler/vendor/thor.rb:263:in `dispatch'
    from /Users/aaron/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.1/lib/bundler/vendor/thor/base.rb:386:in `start'
    from /Users/aaron/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.1/bin/bundle:13:in `<top (required)>'
    from /Users/aaron/.rvm/gems/ruby-1.9.3-p125/bin/bundle:19:in `load'
    from /Users/aaron/.rvm/gems/ruby-1.9.3-p125/bin/bundle:19:in `<main>

This pull request escapes the directory name before it's used in a regexp.

Erik Michaels-Ober sferik merged commit d6f93f8 into from March 23, 2012
Erik Michaels-Ober sferik closed this March 23, 2012
André Arko
Owner

@sferik, thanks for being on top of this, but please please please never merge things without tests. We will just break it again later (or break something else because there's no test). If you're going to merge a pull without a test, write the test, then merge the fix. :)

On a slightly related note, our merge policy means that this should go into the 1-1-stable branch (with a test), and not get merged directly into master. If you have any questions about the merge policy, or future merges, don't hesitate to ping hone or myself. Thanks!

André Arko indirect referenced this pull request from a commit March 23, 2012
André Arko Revert "Merge pull request #1789 from tenderlove/pathescape"
This reverts commit d6f93f8, reversing
changes made to f65ba39.
55ecac9
Erik Michaels-Ober
Collaborator

@indirect Thanks for bringing me up to speed on the policy.
@hone Thanks for writing the test.

I'll be more careful about merging things in the future. Sorry for the trouble.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Mar 23, 2012
Aaron Patterson bundler root path should be escaped ee437f7
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 1 addition and 1 deletion. Show diff stats Hide diff stats

  1. 2  lib/bundler/source.rb
2  lib/bundler/source.rb
@@ -435,7 +435,7 @@ def load_spec_files
435 435
       end
436 436
 
437 437
       def relative_path
438  
-        if path.to_s.match(%r{^#{Bundler.root.to_s}})
  438
+        if path.to_s.match(%r{^#{Regexp.escape Bundler.root.to_s}})
439 439
           return path.relative_path_from(Bundler.root)
440 440
         end
441 441
         path
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.