Skip to content

Modernize pyrnotify#588

Closed
JulienPalard wants to merge 1 commit intoweechat:mainfrom
JulienPalard:mdk-pyrnotify
Closed

Modernize pyrnotify#588
JulienPalard wants to merge 1 commit intoweechat:mainfrom
JulienPalard:mdk-pyrnotify

Conversation

@JulienPalard
Copy link
Contributor

@JulienPalard JulienPalard commented Dec 6, 2025

Script info

  • Script name:  pyrnotify
  • Version: 2.0

Description

As a new user of pyrnotify I proofreaded the code before using it and fixed a few things, sorted by importance (most important first):

  • Fixed a bug where only 1k notifications can be handled due to the 'accept' being called recursively and the Python stack limit being 1k calls by default.
  • Starting a line with a dash, then mentioning me, like -w mdk was crashing notify-send with the Option inconnue -w mdk message (Unknown option -w mdk).
  • Fixed a potential bug in TCP recv code: received bytes were UTF-8 decoded by chunks instead of decoded as a whole, so if a chunk were cutting on a multibyte UTF-8 char both decodes (before and after the cut) would fail. I bet this never occur in practice because message were never truncated (a single TCP packet should always be enough for a notification?).
  • The re.sub(r'([\\"\'])', r'\\\1', s) to serialize arguments in a shell-like form was hurting my eyes, both from a security and from a readability point of view. I did not attempted to exploit it though, maybe it's safe, it just calls to be exploited. I replaced "shell-like-serialization" with json, so we don't have to care about quotes, the json module does.
  • I removed old Python 2 compatibility.
  • I ran black on the code.

I did this "in the rush" to test it for myself, outside the git repo, I'm very sorry it's a single big ugly commit, if needed I'm OK to split this cleanly for easier code review.

Checklist (script update)

  • Author has been contacted
  • Single commit, single file added
  • Commit message format: script_name.py X.Y: …
  • Script version and Changelog have been updated
  • For Python script: works with Python 3 (Python 2 support is optional)
  • Score 100 / 100 displayed by weechat-script-lint
@flashcode
Copy link
Member

Thanks, merged!

With minor changes: tabs removed in comments, fixed a typo in comment.

@flashcode flashcode closed this Dec 7, 2025
@flashcode flashcode self-assigned this Dec 7, 2025
@flashcode flashcode added the feature New feature request label Dec 7, 2025
@JulienPalard JulienPalard deleted the mdk-pyrnotify branch December 7, 2025 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature request

2 participants