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(stdin): trim space instead of \n #761

Merged
merged 1 commit into from
Dec 11, 2024
Merged

fix(stdin): trim space instead of \n #761

merged 1 commit into from
Dec 11, 2024

Conversation

caarlos0
Copy link
Member

we were trimming an ending \n, but it would then break a \r\n sequence, causing misrenders.

this fixes it

closes #682

we were trimming an ending \n, but it would then break a \r\n sequence, causing misrenders.

this fixes it

closes #682

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
@@ -30,7 +30,7 @@ func Read() (string, error) {
}
}

return strings.TrimSuffix(b.String(), "\n"), nil
return strings.TrimSpace(b.String()), nil
Copy link
Contributor

Choose a reason for hiding this comment

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

So you are also trimming on the left.

Please confirm if it intended and OK

Copy link
Member

Choose a reason for hiding this comment

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

Good point. If it matters at all, assuming we'd want strings.TrimRight() to match strings.TrimSuffix.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thought about that, I'm not sure why we were trimming the eof \n... in any case, it's probably fine 🤔

@@ -30,7 +30,7 @@ func Read() (string, error) {
}
}

return strings.TrimSuffix(b.String(), "\n"), nil
return strings.TrimSpace(b.String()), nil
Copy link
Member

Choose a reason for hiding this comment

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

Would this trim \r\n suffixes?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes!

@caarlos0 caarlos0 merged commit b0c9c58 into main Dec 11, 2024
14 checks passed
@caarlos0 caarlos0 deleted the in branch December 11, 2024 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unexpected handling of ascii input text
4 participants