summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author0xAB <0xAB@protonmail.com>2017-09-01 12:48:42 +0100
committer0xAB <0xAB@protonmail.com>2017-09-01 12:48:42 +0100
commit6c781d361d43156b766e5d476937b31eec30b692 (patch)
treed34297ab9ef274489e874bf85cccbede225c6e5f
parent25ecc6fc74b84e7864439422050c1c0fb82853b2 (diff)
downloadpry-6c781d361d43156b766e5d476937b31eec30b692.tar.gz
fix cases where `ls` command could be used to call `Kernel#spawn` and
other methods. eg: Pry.config.ls.heading_color = :puts Pry.config.ls.heading_color = :spawn
-rw-r--r--lib/pry/commands/ls/formatter.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/pry/commands/ls/formatter.rb b/lib/pry/commands/ls/formatter.rb
index 5e30c0de..fdca3586 100644
--- a/lib/pry/commands/ls/formatter.rb
+++ b/lib/pry/commands/ls/formatter.rb
@@ -1,6 +1,7 @@
class Pry
class Command::Ls < Pry::ClassCommand
class Formatter
+ COLOR_METHODS = Pry::Helpers::Text.instance_methods(false)
attr_writer :grep
attr_reader :_pry_
@@ -18,7 +19,12 @@ class Pry
private
def color(type, str)
- Pry::Helpers::Text.send _pry_.config.ls["#{type}_color"], str
+ target = _pry_.config.ls["#{type}_color"]
+ if COLOR_METHODS.include?(target)
+ Pry::Helpers::Text.public_send target, str
+ else
+ str
+ end
end
# Add a new section to the output.