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

Fixes #4060 #4068

Merged
merged 7 commits into from
Mar 1, 2017
Merged
Changes from 2 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
8 changes: 5 additions & 3 deletions src/gzip/header.cr
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class Gzip::Header
xlen = io.read_byte.not_nil!
@extra = Bytes.new(xlen)
io.read_fully(@extra)
else
@extra = Bytes.empty
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is not needed, @extra should always be initialized. Right now it doesn't work because of #3988

end

if flg.name?
Expand Down Expand Up @@ -71,7 +73,7 @@ class Gzip::Header

# flg
flg = Flg::None
flg |= Flg::EXTRA if @extra
flg |= Flg::EXTRA if !@extra.empty?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use unless

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have done...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

flg |= Flg::NAME if @name
flg |= Flg::COMMENT if @comment
io.write_byte flg.value
Expand All @@ -85,8 +87,8 @@ class Gzip::Header
# os
io.write_byte os

if extra = @extra
io.write_byte extra.size.to_u8
if !@extra.empty?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

io.write_byte @extra.size.to_u8
io.write(extra)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this also refer to @extra for consistency?

Copy link
Contributor Author

@crisward crisward Feb 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think you're right. It used to copy the value, I'm guessing there isn't a test case for gzip with extra set. I'll update.

end

Expand Down