]> git.aero2k.de Git - urlbot-v3.git/commit
Fix silently missing titles for pages with a late <title>
authorThorsten <mail@aero2k.de>
Wed, 5 Aug 2026 15:35:58 +0000 (17:35 +0200)
committerThorsten <mail@aero2k.de>
Wed, 5 Aug 2026 15:35:58 +0000 (17:35 +0200)
commit473e7e897d721272b57f6d903aa81ff85720a5a9
tree80fe723436350a1635ebb583de59d4efb3d860b1
parent41dff01497ebf8a95643fa64cb04e99db41adf2c
Fix silently missing titles for pages with a late <title>

fetch_page() only ever read the first 8 KB of a response, so any page
whose <title> sits beyond that (github: byte 24571) produced no title at
all -- the log showed "fetching page ..." and then nothing, and the
plugin published an empty action. Read in chunks until </title> shows
up instead, capped at 512 KB, and skip the body entirely for non-text
responses.

Also along that path:
- decode with errors='replace'; the read boundary can land mid-character
- extract_title() passed user_agent=None, and requests treats a None
  header value as "drop this header", so every non-YouTube fetch went
  out with no User-Agent at all
- the non-text branch returned the tuple (1, content-type), which is
  truthy, so URLResolver called .strip() on it and raised AttributeError
- log a warning on the remaining no-title paths, which were silent
- return None instead of Action(msg="") when nothing resolved

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
src/distbot/common/utils.py
src/distbot/plugins/url.py