improve(tts-voice): 改用 spawnSync 參數陣列避免 shell quoting 問題 #1

Open
yucheng wants to merge 1 commits from yucheng/openclaw-skill:improve/tts-voice-safe-curl-args into main
First-time contributor

改進說明

tts-voice 目前用字串拼接組 curl 指令並透過 execSync 執行。當輸入文字包含引號、跳脫字元或 shell 特殊符號時,容易出現參數被 shell 誤解析的風險,影響可維護性與穩定性。

變更內容

  • child_process 匯入改為 execSync, spawnSync
  • 重構 generateSpeech()
    • 改用 spawnSync('curl', args) + 參數陣列傳遞
    • 移除字串拼接與手動 quote/escape 的做法
    • 成功條件改為同時檢查 result.status === 0、HTTP code 為 200、輸出檔存在
  • 保留原有 timeout、失敗清理邏輯與回傳格式

測試建議

  1. 觸發 tts-voice,測試一般輸入:tts 你好,今天要開會
  2. 測試包含特殊字元:tts 他說: "Hello & Welcome"
  3. 測試失敗路徑(停掉 LuxTTS 或使用錯誤 cookie),確認會回傳失敗並清理暫存檔

🤖 由 yucheng 自動審查並提交

## 改進說明 `tts-voice` 目前用字串拼接組 `curl` 指令並透過 `execSync` 執行。當輸入文字包含引號、跳脫字元或 shell 特殊符號時,容易出現參數被 shell 誤解析的風險,影響可維護性與穩定性。 ## 變更內容 - 將 `child_process` 匯入改為 `execSync, spawnSync` - 重構 `generateSpeech()`: - 改用 `spawnSync('curl', args)` + 參數陣列傳遞 - 移除字串拼接與手動 quote/escape 的做法 - 成功條件改為同時檢查 `result.status === 0`、HTTP code 為 `200`、輸出檔存在 - 保留原有 timeout、失敗清理邏輯與回傳格式 ## 測試建議 1. 觸發 `tts-voice`,測試一般輸入:`tts 你好,今天要開會` 2. 測試包含特殊字元:`tts 他說: "Hello & Welcome"` 3. 測試失敗路徑(停掉 LuxTTS 或使用錯誤 cookie),確認會回傳失敗並清理暫存檔 --- 🤖 由 yucheng 自動審查並提交
yucheng added 1 commit 2026-03-13 12:03:27 +08:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u improve/tts-voice-safe-curl-args:yucheng-improve/tts-voice-safe-curl-args
git checkout yucheng-improve/tts-voice-safe-curl-args
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Selig/openclaw-skill#1