From bf87415adafccbc6387b7db03078a84fdcd9e6cf Mon Sep 17 00:00:00 2001 From: Brandon Keepers Date: Tue, 17 Dec 2024 19:39:30 -0500 Subject: [PATCH 1/2] Preserve repeated linebreaks when normalizing line endings --- lib/dotenv/parser.rb | 2 +- spec/dotenv/parser_spec.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/dotenv/parser.rb b/lib/dotenv/parser.rb index 3ed50f5..d2c0d62 100644 --- a/lib/dotenv/parser.rb +++ b/lib/dotenv/parser.rb @@ -43,7 +43,7 @@ def call(...) def initialize(string, overwrite: false) # Convert line breaks to same format - @string = string.gsub(/[\n\r]+/, "\n") + @string = string.gsub(/\r\n?/, "\n") @hash = {} @overwrite = overwrite end diff --git a/spec/dotenv/parser_spec.rb b/spec/dotenv/parser_spec.rb index 70b191b..e7eebdb 100644 --- a/spec/dotenv/parser_spec.rb +++ b/spec/dotenv/parser_spec.rb @@ -158,6 +158,11 @@ def env(...) .to eql("foo" => "bar", "fizz" => "buzz") end + it "does not ignore empty lines in quoted string" do + value = "a\n\nb\n\nc" + expect(env("FOO=\"#{value}\"")).to eql("FOO" => value) + end + it "ignores inline comments" do expect(env("foo=bar # this is foo")).to eql("foo" => "bar") end From 19a767531d584242582782e44f37a2090b010755 Mon Sep 17 00:00:00 2001 From: Brandon Keepers Date: Tue, 17 Dec 2024 19:45:37 -0500 Subject: [PATCH 2/2] Prepare for 3.1.7 release --- Changelog.md | 6 ++++++ lib/dotenv/version.rb | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index 5fa98f8..14bf791 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,12 @@ [Unreleased changes](https://github.com/bkeepers/dotenv/compare/v3.1.6...main) +## 3.1.7 + +* Fix issue with repeated linebreaks when normalizing line endings by @bkeepers in https://github.com/bkeepers/dotenv/pull/523 + +**Full Changelog**: https://github.com/bkeepers/dotenv/compare/v3.1.6...v3.1.7 + ## 3.1.6 * Fix: Restore previous parser behavior of returning existing variables by @bkeepers in https://github.com/bkeepers/dotenv/pull/519 diff --git a/lib/dotenv/version.rb b/lib/dotenv/version.rb index 0025ce9..2af9d29 100644 --- a/lib/dotenv/version.rb +++ b/lib/dotenv/version.rb @@ -1,3 +1,3 @@ module Dotenv - VERSION = "3.1.6".freeze + VERSION = "3.1.7".freeze end