Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions gateway/delivery.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def _deliver_local(
lines.append("")
lines.append(content)

output_path.write_text("\n".join(lines))
output_path.write_text("\n".join(lines), encoding="utf-8")

return {
"path": str(output_path),
Expand All @@ -291,7 +291,7 @@ def _save_full_output(self, content: str, job_id: str) -> Path:
out_dir = get_hermes_home() / "cron" / "output"
out_dir.mkdir(parents=True, exist_ok=True)
path = out_dir / f"{job_id}_{timestamp}.txt"
path.write_text(content)
path.write_text(content, encoding="utf-8")
return path

def _filter_silence_narration_enabled(self) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion gateway/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -8001,7 +8001,7 @@ async def _handle_message(self, event: MessageEvent) -> Optional[str]:
prompt_path = _hermes_home / ".update_prompt.json"
try:
tmp = response_path.with_suffix(".tmp")
tmp.write_text(response_text)
tmp.write_text(response_text, encoding="utf-8")
tmp.replace(response_path)
prompt_path.unlink(missing_ok=True)
except OSError as e:
Expand Down
2 changes: 1 addition & 1 deletion plugins/platforms/discord/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6206,7 +6206,7 @@ async def _respond(
home = get_hermes_home()
response_path = home / ".update_response"
tmp = response_path.with_suffix(".tmp")
tmp.write_text(answer)
tmp.write_text(answer, encoding="utf-8")
tmp.replace(response_path)
logger.info(
"Discord update prompt answered '%s' by %s",
Expand Down
2 changes: 1 addition & 1 deletion plugins/platforms/feishu/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2100,7 +2100,7 @@ def _build_resolved_update_prompt_card(*, answer: str, user_name: str) -> Dict[s
def _write_update_prompt_response(answer: str) -> None:
response_path = get_hermes_home() / ".update_response"
tmp_path = response_path.with_suffix(".tmp")
tmp_path.write_text(answer)
tmp_path.write_text(answer, encoding="utf-8")
tmp_path.replace(response_path)

async def send_voice(
Expand Down
2 changes: 1 addition & 1 deletion plugins/platforms/telegram/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4805,7 +4805,7 @@ async def _handle_callback_query(
home = get_hermes_home()
response_path = home / ".update_response"
tmp = response_path.with_suffix(".tmp")
tmp.write_text(answer)
tmp.write_text(answer, encoding="utf-8")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please include the equivalent QQBot update-response writer at gateway/platforms/qqbot/adapter.py:1204; it uses the same tmp.write_text(answer) pattern and remains vulnerable on Windows.

tmp.replace(response_path)
logger.info("Telegram update prompt answered '%s' by user %s",
answer, getattr(query.from_user, "id", "unknown"))
Expand Down
6 changes: 3 additions & 3 deletions tools/skills_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -987,7 +987,7 @@ def _write_cache(self, key: str, data: list) -> None:
INDEX_CACHE_DIR.mkdir(parents=True, exist_ok=True)
cache_file = INDEX_CACHE_DIR / f"{key}.json"
try:
cache_file.write_text(json.dumps(data, ensure_ascii=False))
cache_file.write_text(json.dumps(data, ensure_ascii=False), encoding="utf-8")
except OSError as e:
logger.debug("Could not write cache: %s", e)

Expand Down Expand Up @@ -3180,7 +3180,7 @@ def _write_index_cache(key: str, data: Any) -> None:
pass
cache_file = INDEX_CACHE_DIR / f"{key}.json"
try:
cache_file.write_text(json.dumps(data, ensure_ascii=False, default=str))
cache_file.write_text(json.dumps(data, ensure_ascii=False, default=str), encoding="utf-8")
except OSError as e:
logger.debug("Could not write cache: %s", e)

Expand Down Expand Up @@ -3220,7 +3220,7 @@ def load(self) -> dict:

def save(self, data: dict) -> None:
self.path.parent.mkdir(parents=True, exist_ok=True)
self.path.write_text(json.dumps(data, indent=2, ensure_ascii=False) + "\n")
self.path.write_text(json.dumps(data, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")

def record_install(
self,
Expand Down