Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions problemtools/ProblemPlasTeX/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ def getImage(self, node):
newext = self.imageConversion[oldext][0]
path = os.path.splitext(path)[0] + newext
cmd = self.imageConversion[oldext][1] + [path, name]
status = subprocess.call(cmd)
if status:
log.warning('Failed to convert %s image "%s to %s', oldext, name, newext)
result = subprocess.run(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE)
if result.returncode:
log.error(f'Failed to convert {oldext} image {name} to {newext}.\n{result.stderr.decode(errors="replace")}')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When logging, you want to keep printf-formatting instead of using an f-string if the data is not strictly controlled.

This will crash if any of the strings contain something looking like a printf specifier (e.g., if the error message from ghostscript happens to conrtain %s).

else:
# Just copy it
path = os.path.splitext(path)[0] + oldext
Expand Down
Loading