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

caddyfile: Allow heredoc blank lines #6051

Merged

Conversation

armadi1809
Copy link
Contributor

Closes #6048

@francislavoie. This seemed quick, so I thought I would take a crack at it.

@francislavoie
Copy link
Member

We need tests to cover this.

@francislavoie
Copy link
Member

I don't think it's valid to have partial whitespace on the line, that's weird. Also I don't think we should remove whitespace if they include it (the whitespace may be important to the user, it should be preserved).

@armadi1809
Copy link
Contributor Author

So what you're saying is no need to account for the fact where the blank line is not really empty but contains whitespaces? Also, I thought I am not removing any whitespaces as I am only checking for the output of the TrimSpace function but not assigning it to anything.

@francislavoie
Copy link
Member

I think a heredoc indented with 2 tabs, having an "empty" line with only 1 tab, is not valid.

I also think a heredoc with 2 tabs, having an "empty" line with 3 tabs is valid, and it should preserve that 1 tab as real text (after stripping the leading 2 tabs)

@armadi1809
Copy link
Contributor Author

@francislavoie I think it should now cover the cases you mentioned. I also added test cases but please let me know if we need more. Thanks.

caddyconfig/caddyfile/lexer.go Outdated Show resolved Hide resolved
caddyconfig/caddyfile/lexer.go Outdated Show resolved Hide resolved
caddyconfig/caddyfile/lexer_test.go Show resolved Hide resolved
@francislavoie francislavoie added the bug 🐞 Something isn't working label Jan 19, 2024
@francislavoie francislavoie added this to the v2.8.0 milestone Jan 19, 2024
@francislavoie francislavoie changed the title Skip stripping when dealing with new lines in heredoc caddyfile: Allow heredoc blank lines Jan 19, 2024
@armadi1809
Copy link
Contributor Author

All the feedback items above should now be resolved. Thank you for your prompt feedback @francislavoie!

Copy link
Member

@francislavoie francislavoie left a comment

Choose a reason for hiding this comment

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

Great, thanks!

@francislavoie francislavoie enabled auto-merge (squash) January 19, 2024 02:57
@francislavoie
Copy link
Member

Hmm, the CLA bot is down, I think. I guess we'll have to wait for it to wake up 😂 but that's fine

@francislavoie francislavoie merged commit d9aded0 into caddyserver:master Jan 19, 2024
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow blank lines in Heredoc
2 participants