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

Core/ircparser: Only trim whitespace from the end of the last parameter. #587

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

genius3000
Copy link
Contributor

@genius3000 genius3000 commented Jun 27, 2021

In Brief

  • Current behaviour is trimming both leading and trailing spaces.
  • Corrected behaviour only trims trailing whitespace, as was the intention going by the commit messages and comment.

Impact

Criteria Rank Reason
Impact ★☆☆ 1/3 Prevents unwanted trimming of leading whitespace when trailing whitespace existed.
Risk ★☆☆ 1/3 Can't think of anything.
Intrusiveness ★☆☆ 1/3 Small change; diffs look like it won't affect other PRs even in the same file.

Rationale

Essentially the same as the In Brief section. Trimming trailing space is rarely, if any, noticed but trimming leading spaces was unintentional and can ruin a line's formatting.
Reference Issue #1733.

Testing

Had a MOTD line with a trailing space that provided a nice test case:

2021-06-26 05:18:49 [Debug] orig: "     ,'__/_ ___ _  `. "
2021-06-26 05:18:49 [Debug] orig trim:  ",'__/_ ___ _  `."
2021-06-26 05:18:49 [Debug] new trim:  "     ,'__/_ ___ _  `."

Disclaimer

I know this change is kind of ugly, with a trim function implemented directly here. I did not see anywhere else that would benefit from a new Quassel function of rtrim. Totally open to other ideas though.

QString::trimmed() removes both leading and trailing whitespace, which
is not the intention here. As QString does not have a ltrim/rtrim
function, we need to implement the equivalent here to only trim the
trailing whitespace.

As QString::trimmed() removed any whitespace for which QChar::isSpace()
returns true, I have switched the trailing whitespace check to use the
same function.

This fixes #1733.
@deviant
Copy link
Contributor

deviant commented Jun 27, 2021

Oh, I think this will fix a bug I noticed where Quassel would for some reason strip the indentation from a few lines of the MOTD of a server I'm on. I understand why, now: these lines had trailing whitespace, which triggered the stripping logic.

@justjanne
Copy link
Contributor

Why is it even trimmed at all? Ideally we'd keep the content completely intact.

@genius3000
Copy link
Contributor Author

@justjanne from the commits, it was initially due to trailing spaces in a NAMREPLY causing empty nicks to be created.
Commits 9fe8b83 and 9e637b2.
Those are from a number of years ago and this trimming is just a safety from edge cases (imo). Is this something we can build a test against (I'm completely unfamiliar with the/any test suite) to be fairly certain we don't introduce any regressions by removing this trimming?

@genius3000 genius3000 marked this pull request as ready for review July 6, 2021 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants