View Issue Details

IDProjectCategoryView StatusLast Update
0011813Dwarf FortressDwarf Mode -- Interface, Announcementspublic2023-11-24 09:49
ReporterBumber Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
Product Version0.47.05 
Summary0011813: '&' in nickname messes with announcement text
DescriptionIt looks like the announcement and report code uses '&' as an escape sequence. Putting "&r" in a dwarf's nickname or profession will split the announcement at that point and continue the rest two lines down. In other combinations, the '&' will display, but the next character in the string will be ignored.

'&' in user text needs to be sanitized to "&&" at some point before ending up in an announcement.
TagsNo tags attached.

Activities

Bumber

2021-10-25 00:53

reporter   ~0041165

There's also an issue in the related code where use of enough ampersands will cause the line to be cut at the wrong index, deleting text. I set custom professions on my sparring dwarves as "&&aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&" and "&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&".

gamelog.txt shows:
"The &&aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa& strikes at the &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& but the shot is blocked!"

Sparring report shows:
"The &aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
&&&&&&&&&&&&&&&&&&&but the shot is blocked!"

Bumber

2021-10-25 01:01

reporter   ~0041166

Last edited: 2021-10-25 22:40

(There's also a hypothetical crash that could occur if the index to cut the line at underflows as a result of the above, but you'd need 71+ consecutive characters without a space on the smallest grid size of 80.)

Bumber

2023-11-22 05:25

reporter   ~0041892

Last edited: 2023-11-24 09:49

So, the announcement system was redone for v50. The issue in the above comments was fixed. The underlying issue with sanitizing input remains, unfortunately. You can use '[' in nicknames and profession to pass in tokens to the markup text box parser (used by popup/mega announcements, legends mode, etc.)

For example, nicknaming a dwarf "[C:4:0:0]Urist" will turn "Urist" and all following text in the text box red until something resets the color.

The regular announcement text isn't parsed, so the solution isn't as simple as replacing "[" with "[[", or else you'll get "[[C:4:0:0]]Urist, Swordsdwarf has bestowed" everywhere outside the popup. Disallowing '[' in nicknames might be too restrictive.

Add Note

Note

Issue History

Date Modified Username Field Change
2021-10-05 06:39 Bumber New Issue
2021-10-25 00:53 Bumber Note Added: 0041165
2021-10-25 01:01 Bumber Note Added: 0041166
2021-10-25 22:40 Bumber Note Edited: 0041166
2023-11-22 05:25 Bumber Note Added: 0041892
2023-11-24 09:49 Bumber Note Edited: 0041892