Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with repeated linebreaks when normalizing line endings #523

Merged
merged 2 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/dotenv/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/dotenv/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Dotenv
VERSION = "3.1.6".freeze
VERSION = "3.1.7".freeze
end
5 changes: 5 additions & 0 deletions spec/dotenv/parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading