[GH-ISSUE #307] Backslash ( \ ) in chants.json breaks the chant feature #211

Closed
opened 2026-10-30 21:21:05 +00:00 by bsakaguchi · 2 comments
Owner

Originally created by @blue-popsicle on GitHub (Oct 31, 2024).
Original GitHub issue: https://github.com/DominikDoom/a1111-sd-webui-tagcomplete/issues/307

Some chants I want to put in the chants.json file need to include the backslash ( \ ) character due to tags which include parentheses.

However, putting a backslash anywhere in the chants.json file breaks the Webui's ability to load any chants at all.

Seems to be another broken sanitization rule similar to Issue #267

Originally created by @blue-popsicle on GitHub (Oct 31, 2024). Original GitHub issue: https://github.com/DominikDoom/a1111-sd-webui-tagcomplete/issues/307 Some chants I want to put in the chants.json file need to include the backslash ( \ ) character due to tags which include parentheses. However, putting a backslash anywhere in the chants.json file breaks the Webui's ability to load any chants at all. Seems to be another broken sanitization rule similar to Issue #267
Author
Owner

@DominikDoom commented on GitHub (Oct 31, 2024):

The loading and sanitization is fine, I think your issue is rather not escaping the char in the JSON itself.
\ is an escape sequence marker, so writing \( in JSON will be invalid. It expects an actual sequence like \n (newline) or \" to escape a double quote inside the string. For a literal \, you have to double it: \\.

To summarize:

  • artoria_pendragon_(fate) Default
  • artoria_pendragon_\(fate\) Invalid JSON syntax, will break the file
  • artoria_pendragon_\\(fate\\) Works and will output what you expect

I would recommend editing JSON in an editor with syntax highlighting, e.g. VSCode:
image
image
Or Notepad++:
image

That will make spotting such errors easy.

<!-- gh-comment-id:2449748751 --> @DominikDoom commented on GitHub (Oct 31, 2024): The loading and sanitization is fine, I think your issue is rather not escaping the char in the JSON itself. `\` is an escape sequence marker, so writing `\(` in JSON will be invalid. It expects an actual sequence like `\n` (newline) or `\"` to escape a double quote inside the string. For a literal `\`, you have to double it: `\\`. To summarize: - `artoria_pendragon_(fate)` Default - `artoria_pendragon_\(fate\)` Invalid JSON syntax, will break the file - `artoria_pendragon_\\(fate\\)` Works and will output what you expect I would recommend editing JSON in an editor with syntax highlighting, e.g. VSCode: ![image](https://github.com/user-attachments/assets/9d92f47d-d013-4d3c-b905-1c42b5efb859) ![image](https://github.com/user-attachments/assets/0a6fb746-a594-452f-ada6-ec71edabe3cc) Or Notepad++: ![image](https://github.com/user-attachments/assets/b2cef8d4-83ed-423e-bad8-4c9441a0a4d7) That will make spotting such errors easy.
Author
Owner

@blue-popsicle commented on GitHub (Nov 2, 2024):

Ahhh, I see, that makes sense. Thank you for the explanation! I got it working properly.

<!-- gh-comment-id:2452928674 --> @blue-popsicle commented on GitHub (Nov 2, 2024): Ahhh, I see, that makes sense. Thank you for the explanation! I got it working properly.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
DominikDoom/a1111-sd-webui-tagcomplete#211
No description provided.