[pass] [PATCH] Normalize line endings in 1Password importer
Tobias V. Langhoff
tobias at langhoff.no
Wed May 25 00:24:22 CEST 2016
Fix 1Password importer so it handles different line endings
---
contrib/importers/1password2pass.rb | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/contrib/importers/1password2pass.rb
b/contrib/importers/1password2pass.rb
index 79318ee..5ea4523 100755
--- a/contrib/importers/1password2pass.rb
+++ b/contrib/importers/1password2pass.rb
@@ -95,8 +95,10 @@ if File.extname(filename) =~ /.txt/i
elsif File.extname(filename) =~ /.1pif/i
require "json"
- # 1PIF is almost JSON, but not quite
pif = "[#{File.open(filename).read}]"
+ # Normalize line endings, explicitly preserving encoding just to be sure
+ pif.encode!(pif.encoding, universal_newline: true)
+ # 1PIF is almost JSON, but not quite:
pif.gsub!(/^\*\*\*.*\*\*\*$/, ",")
pif = JSON.parse(pif, {symbolize_names: true})
--
Tobias V. Langhoff
More information about the Password-Store
mailing list