[1.2.2753] Brackets in item labels break grammar resolution

Started by jamaicancastle, February 01, 2021, 08:17:18 PM

Previous topic - Next topic

jamaicancastle

Related to this bug about character names, Thing labels that include brackets [] break the grammar resolver when, e.g., they find their way into the battle log.

Specifically this was discovered with a modded bullet with brackets in its label. Looking at the resolver log, other possible sources of brackets include: weapon, PawnKindDef, and BodyPartDef labels, backstory titles (either abbreviated or full), or faction names. There may be others.

With the brackets removed, the log works fine. In the linked thread, disallowing brackets in pawn names was mentioned by Tynan as a solution; that would be fine here, but if that is the case, a ConfigError should be raised, similar to when a def has a defName that isn't allowed.

The other approach would be to sanitize input when loading custom rules from fields such as labels, perhaps by omitting the brackets or replacing them with parentheses or another allowed character. A label of "[test] my item" might be changed to "test my item" or "(test) my item" before handing it off to the grammar resolver.

A grammar resolution trace is attached. Note line 4, where the label "[LC] Solemn Vow Bullet LC" creates a spurious, unresolveable "LC" element.

Pheanox

Thanks for this report, it's been added to a list of things to address.