This repository has been archived by the owner on Apr 14, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2k
namespace pollution in loading local gemspec #5958
Labels
Comments
From 0e0bfd7db38102f75308e01e25b937970b992e25 Mon Sep 17 00:00:00 2001
From: "Urabe, Shyouhei" <shyouhei@ruby-lang.org>
Date: Sun, 20 Aug 2017 15:16:18 +0900
Subject: [PATCH] proposed fix.
Signed-off-by: Urabe, Shyouhei <shyouhei@ruby-lang.org>
---
lib/bundler.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/bundler.rb b/lib/bundler.rb
index c6d68c49d..aba63fb53 100644
--- a/lib/bundler.rb
+++ b/lib/bundler.rb
@@ -479,7 +479,7 @@ EOF
end
def eval_gemspec(path, contents)
- eval(contents, TOPLEVEL_BINDING, path.expand_path.to_s)
+ eval(contents, TOPLEVEL_BINDING.dup, path.expand_path.to_s)
rescue ScriptError, StandardError => e
msg = "There was an error while loading `#{path.basename}`: #{e.message}"
--
2.14.1 |
If you could send in a PR with a test for this, that'd be awesome. Thanks! |
bundlerbot
added a commit
that referenced
this issue
Aug 20, 2017
Avoid namespace pollution fixes #5958. ### What was the end-user problem that led to this PR? The problem was that local variables are magically introduced into the global toplevel, when there is a local gemspec that has such local variables. ### What was your diagnosis of the problem? My diagnosis was that `TOPLEVEL_BINDING` is used with `eval` ### What is your fix for the problem, implemented in this PR? My fix is to duplicate that binding. ### Why did you choose this fix out of the possible options? I chose this fix because it is clean and concise. Other possible options are like reinventions of wheel.
bundlerbot
added a commit
that referenced
this issue
Aug 21, 2017
Avoid namespace pollution fixes #5958. ### What was the end-user problem that led to this PR? The problem was that local variables are magically introduced into the global toplevel, when there is a local gemspec that has such local variables. ### What was your diagnosis of the problem? My diagnosis was that `TOPLEVEL_BINDING` is used with `eval` ### What is your fix for the problem, implemented in this PR? My fix is to duplicate that binding. ### Why did you choose this fix out of the possible options? I chose this fix because it is clean and concise. Other possible options are like reinventions of wheel.
bundlerbot
added a commit
that referenced
this issue
Aug 22, 2017
Avoid namespace pollution fixes #5958. ### What was the end-user problem that led to this PR? The problem was that local variables are magically introduced into the global toplevel, when there is a local gemspec that has such local variables. ### What was your diagnosis of the problem? My diagnosis was that `TOPLEVEL_BINDING` is used with `eval` ### What is your fix for the problem, implemented in this PR? My fix is to duplicate that binding. ### Why did you choose this fix out of the possible options? I chose this fix because it is clean and concise. Other possible options are like reinventions of wheel.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
What you're trying to accomplish
Clean local variables
The command you ran
What you expected to happen
empty output at the last command
What actually happened
is shown.
The exception backtrace(s), if any
no.
Everything output by running bundle env
Gemfile
Gemfile
gemspec
Gemfile.lock
Gemspecs
bundler-pollution.gemspec
The text was updated successfully, but these errors were encountered: