If the user cannot enter user code, but only format the lines, then you can avoid print-object problems. Remember to use with-standard-io-syntax (or its customized version) to control the exact type of output you will create (think of *print-base* , ...).
You can scan the input lines to detect the presence of ~/ (but ~~/ ) and refuse to interpret the format that contains blacklists. However, some analyzes are more complicated, and you may need to act at runtime.
For example, if the format string is incorrect, you will probably get an error that needs to be handled (you can also give bad values โโto the expected arguments).
Even if the user is not malicious, you may also have problems with iteration constructs:
~{<X>~:*~}
... never stops because ~:* rewinds the current argument. To deal with this, you must consider that <X> may or may not print anything. You can implement both of these strategies:
- has a timeout to limit time formatting.
- if the record is too large (for example, writing to a string buffer), the main stream reaches the end of the file.
There may be other problems that I donโt see right now, be careful.
source share