diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-04-24 17:54:54 +0900 |
---|---|---|
committer | aycabta <aycabta@gmail.com> | 2020-04-29 19:13:14 +0900 |
commit | 0ac5009165e0d743b82ac673d4eb98e871f4ea0b (patch) | |
tree | 5090dd46cf6dbaf79a77545fbe9586e852e42f44 /lib | |
parent | e801e9ba65f6d98f6fee32a1e7e553e6586230cd (diff) | |
download | ruby-0ac5009165e0d743b82ac673d4eb98e871f4ea0b.tar.gz |
[ruby/reline] Ignore non-absolute XDG_CONFIG_HOME
https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
> All paths set in these environment variables must be absolute.
> If an implementation encounters a relative path in any of these
> variables it should consider the path invalid and ignore it.
https://github.com/ruby/reline/commit/45af6eea77
Diffstat (limited to 'lib')
-rw-r--r-- | lib/reline/config.rb | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/reline/config.rb b/lib/reline/config.rb index b299bcc9cd..fd761aeb21 100644 --- a/lib/reline/config.rb +++ b/lib/reline/config.rb @@ -94,15 +94,16 @@ class Reline::Config home_rc_path = File.expand_path('~/.inputrc') return home_rc_path if File.exist?(home_rc_path) - case ENV['XDG_CONFIG_HOME'] + case path = ENV['XDG_CONFIG_HOME'] when nil, '' - path = File.expand_path('~/.config/readline/inputrc') - return path if File.exist?(path) else - path = File.expand_path("#{ENV['XDG_CONFIG_HOME']}/readline/inputrc") - return path if File.exist?(path) + path = File.join(path, 'readline/inputrc') + return path if File.exist?(path) and path == File.expand_path(path) end + path = File.expand_path('~/.config/readline/inputrc') + return path if File.exist?(path) + return home_rc_path end |