hermes-agent/skills/productivity/pdf/scripts
solyanviktor-star adecb0d1a9 fix(skills): read OOXML parts as bytes and form JSON as UTF-8 in office skill scripts
The bundled office skills (#68595) read user documents and agent-authored
payloads with the locale-default codec:

- docx/powerpoint validators/base.py opened OOXML part XML in text mode
  before handing it to lxml. On Windows (cp1251/GBK) the bytes decode to
  mojibake that lxml then parses, so validation runs against silently
  corrupted document text; on locales where the UTF-8 bytes don't decode
  the validator crashes with UnicodeDecodeError instead of validating.
  Opening as bytes lets lxml honor the encoding declared in the XML prolog.

- The pdf form scripts (fill_fillable_fields, fill_pdf_form_with_annotations,
  create_validation_image, check_bounding_boxes) read the fields JSON the
  agent authors — UTF-8 by construction — with the locale codec, so
  non-ASCII form values (any Cyrillic/CJK/accented input) either crash or
  get written into the user's PDF as mojibake. The json.dump writers use
  ensure_ascii=True and were already safe; only the readers needed pinning.

Adds a contract test asserting every document/payload reader is
locale-independent, plus a live regression test that runs
check_bounding_boxes.py on a non-ASCII fields.json under a forced
non-UTF-8 locale — it fails without the fix on both POSIX (C locale)
and Windows (cp1251 chokes on the 0x98 byte of U+2018).
2026-07-24 17:10:39 -07:00
..
check_bounding_boxes.py fix(skills): read OOXML parts as bytes and form JSON as UTF-8 in office skill scripts 2026-07-24 17:10:39 -07:00
check_fillable_fields.py
convert_pdf_to_images.py
create_validation_image.py fix(skills): read OOXML parts as bytes and form JSON as UTF-8 in office skill scripts 2026-07-24 17:10:39 -07:00
extract_form_field_info.py
extract_form_structure.py
fill_fillable_fields.py fix(skills): read OOXML parts as bytes and form JSON as UTF-8 in office skill scripts 2026-07-24 17:10:39 -07:00
fill_pdf_form_with_annotations.py fix(skills): read OOXML parts as bytes and form JSON as UTF-8 in office skill scripts 2026-07-24 17:10:39 -07:00