1
0
Fork 0
mirror of https://github.com/ganelson/inform.git synced 2024-05-03 09:40:19 +03:00

Escape escape characters in regular expression strings

The %s here is a format specifier for WRITE_TO(), and the %c's are regular
expression character classes. The %c's must be double-escaped so that the
formatter doesn't choke due to there being too few variable arguments.

This prevents a crash in inblorb when releasing along with a solution.
This commit is contained in:
Philip Chimento 2022-05-16 22:40:12 -07:00
parent a024c4ba9c
commit df155e8110

View file

@ -167,7 +167,7 @@ void Solution::read_skein_line(text_stream *line, int pass) {
= =
void Solution::find_node_ID_in_tag(OUTPUT_STREAM, text_stream *line, char *tag) { void Solution::find_node_ID_in_tag(OUTPUT_STREAM, text_stream *line, char *tag) {
TEMPORARY_TEXT(prototype) TEMPORARY_TEXT(prototype)
WRITE_TO(prototype, "%c*?<%s nodeId=\"(%c*?)\"%c*", tag); WRITE_TO(prototype, "%%c*?<%s nodeId=\"(%%c*?)\"%%c*", tag);
wchar_t prototype_Cs[128]; wchar_t prototype_Cs[128];
Str::copy_to_wide_string(prototype_Cs, prototype, 128); Str::copy_to_wide_string(prototype_Cs, prototype, 128);
match_results mr = Regexp::create_mr(); match_results mr = Regexp::create_mr();
@ -182,7 +182,7 @@ void Solution::find_node_ID_in_tag(OUTPUT_STREAM, text_stream *line, char *tag)
= =
int Solution::find_text_of_tag(OUTPUT_STREAM, text_stream *line, char *tag) { int Solution::find_text_of_tag(OUTPUT_STREAM, text_stream *line, char *tag) {
TEMPORARY_TEXT(prototype) TEMPORARY_TEXT(prototype)
WRITE_TO(prototype, "%c*?>(%c*?)</%s%c*", tag); WRITE_TO(prototype, "%%c*?>(%%c*?)</%s%%c*", tag);
match_results mr = Regexp::create_mr(); match_results mr = Regexp::create_mr();
wchar_t prototype_Cs[128]; wchar_t prototype_Cs[128];
Str::copy_to_wide_string(prototype_Cs, prototype, 128); Str::copy_to_wide_string(prototype_Cs, prototype, 128);