| 1 | import fontforge |
| 2 | |
| 3 | # This test checks whether strings passed to fontforge for Python cause crashes |
| 4 | # due to % not being escaped and forwarded to printf with invalid format |
| 5 | # specifier or missing arguments. |
| 6 | |
| 7 | # Formatting is done completely from python and these functions accept only a |
| 8 | # single string argument. |
| 9 | |
| 10 | # shouldn't produce a warning |
| 11 | fontforge.logWarning("SANITIZATION %% CHECK") |
| 12 | # should produce a warning |
| 13 | fontforge.logWarning("SANITIZATION % CHECK") |
| 14 | # should produce a single warning |
| 15 | fontforge.logWarning("%SANIT%IZATION CHECK%") |
| 16 | |
| 17 | # Titles aren't formatted at the moment, but they're tested here anyway as a |
| 18 | # sanity check in case future versions pass the dialog title to printf. |
| 19 | |
| 20 | # shouldn't produce a warning |
| 21 | fontforge.postError("%%POSTERROR", "SANITIZATION %% CHECK") |
| 22 | # should produce a warning |
| 23 | fontforge.postError("POST % ERROR%", "SANITIZATION % CHECK") |
| 24 | # should produce a single warning |
| 25 | fontforge.postError("%POST ER%ROR%", "%SANIT%IZATION CHECK%") |
| 26 | |
| 27 | # shouldn't produce a warning |
| 28 | fontforge.postNotice("POST %% NOTICE", "SANITIZATION %% CHECK") |
| 29 | # should produce a warning |
| 30 | fontforge.postNotice("POST % NOTICE", "SANITIZATION % CHECK") |
| 31 | # should produce a single warning |
| 32 | fontforge.postNotice("%POST %NOT%ICE%", "%SANIT%IZATION CHECK%") |