Skip to content

Conversation

@dgw
Copy link
Member

@dgw dgw commented May 2, 2023

Description

Some use cases involving bot.say() (text with no truncation and no continuation, i.e. the majority of that method's uses throughout core and third-party plugins alike) did not truncate long text correctly.

It seems that incorrectly written tests passed anyway, letting the incorrect behavior appear as if it was correct.

I've verified that without this change, #2314 was still reproducible using the sopel-ipython console plugin on e5bcd1f (master as of writing); and with this change, I could no longer reproduce that behavior.

Checklist

  • I have read CONTRIBUTING.md
  • I can and do license this contribution under the EFLv2
  • No issues are reported by make qa (runs make quality and make test)
  • I have tested the functionality of the things this change touches

Notes

This PR was opened early because I'm a cheeky bastard and want to make number 2450 a PR that we'd definitely ship.

In certain cases (such as `max_messages=1` with no `trailing` or
`truncation` parameters, i.e. how most `bot.say()` calls are written),
Sopel seems to have been skipping the message truncation step, as
evidenced by manual test results involving strings of emoji that the
IRC server would further truncate in the middle of UTF-8 sequences
(given the correct-length test bot nick/hostmask).

Length values calculated by the tests in question (used for building
test strings dynamically instead of hard-coding 400-plus-byte literals)
only took into account the size of the PRIVMSG *sent by Sopel*, without
the hostmask prefix added by the IRC server when forwarding the message
to other clients.

This is a lesson in making sure the tests are correct, because a passing
test case means nothing if what it checks is wrong.
@dgw dgw force-pushed the bot.say-fix-safe-length branch from a4b4ef2 to 43baee1 Compare May 3, 2023 01:08
@dgw dgw requested a review from a team May 3, 2023 01:09
@dgw dgw marked this pull request as ready for review May 3, 2023 01:09
@dgw dgw linked an issue May 3, 2023 that may be closed by this pull request
@dgw dgw added the Bugfix Generally, PRs that reference (and fix) one or more issue(s) label May 3, 2023
@SnoopJ
Copy link
Contributor

SnoopJ commented May 23, 2023

@dgw (poke) does this need anything to be merged?

@dgw
Copy link
Member Author

dgw commented May 24, 2023

@SnoopJ Usually that's something the PR author asks reviewers, but y'all already approved this one 😁

I'll get to it through the week, while I avoid Real Work™ on PRs that aren't approved yet in favor of meeting $work deadlines.

@dgw dgw merged commit 30a5aae into master May 29, 2023
@dgw dgw deleted the bot.say-fix-safe-length branch May 29, 2023 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bugfix Generally, PRs that reference (and fix) one or more issue(s) Core/IRC Protocol Handling High Priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

say() does not prevent unicode character truncation

4 participants