AUTOMATIC1111 / stable-diffusion-webui

Stable Diffusion web UI
GNU Affero General Public License v3.0
143.29k stars 26.99k forks source link

fix prompt-bracket-checker miscounting of literal tokens #16669

Closed w-e-w closed 2 days ago

w-e-w commented 2 days ago

Description

Current the prompt-bracket-checker.js treats literal tokens as normal tokens

brackets and parentheses proceeded with a slash \( \) are literal

this is wrong

this can easily be fixed by modifying the regex to so it does not count tokens proceeded by a \

internal prompt parser for reference https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/82a973c04367123ae98bd9abdf80d9eda9b910e2/modules/prompt_parser.py#L370-L382

this is not too big of an issue most of the time as if you have a literal opening token in prompts, you would almost alwase have a literal closing token

the internal prompt parser dose handles miss match (()or strangely ordered )( brackets

Screenshots/videos:

Current image image

Fixed image image

test sample text

should error

Current prompt-bracket-checker.js treats \( literal brackets and parentheses )
\(parentheses proceeded with a slash\) are treated as normal brackets
this is wrong, this SHOUD error
the literal parentheses on the 1st line shoud NOT be counted
resulting an extra closeing parentheses on 1st line

should not error

while this \( should NOT error
as the parentheses on the first line is literal

Checklist: