freeCodeCamp / LearnToCodeRPG

A visual novel video game where you learn to code and get a dev job 🎯
https://www.freecodecamp.org/news/learn-to-code-rpg-1-5-update/
BSD 3-Clause "New" or "Revised" License
1.06k stars 110 forks source link

fix: escape strings displayed with `renpy.say()` #73

Closed googlebleh closed 2 years ago

googlebleh commented 2 years ago

These strings are only used for display by renpy.say(), which interprets Python percent-substitutions for Store Variables, so we need to escape '%' characters that we intend to display.

Checklist:

Closes #60

googlebleh commented 2 years ago

I'm fairly sure the reported exception is caused by one of these two questions

cwee@cwee-HP-ZBook-Studio-G7 22:36:53 ~/repos/LearnToCodeRPG fix/renpy_say_format
$ grep -rn "question.*%"
game/scripts/quiz_questions_from_csv.rpy:781:    question=_("Which one of these values represents 10% of the viewport width?"),
game/scripts/quiz_questions_from_csv.rpy:797:    question=_("Which one of these values represents 20% of the viewport height?"),

in addition to the renpy.say() call on line 41 as depicted in #60, an exception can also be triggered by the one on 184. the other calls to renpy.say() don't print any strings with %s in them

escaping these specific strings (rather than auto-escaping %s at runtime) allows us to use percent interpolation in the future. these don't need to be fixed in upstream questions since this is specific to renpy, though you may consider an import script that automatically escapes the imported questions

these strings do not appear to be used anywhere else, so this shouldn't affect other functionality