Skip to content

Commit

Permalink
Fix #2045 - immunize against non-UTF8 encoded fontnames
Browse files Browse the repository at this point in the history
Python C function `Py_BuildValue("s", fontname)` will fail if fontname is not UTF8-encoded.
Use PyUnicodeRawEscape function for fontnames instead - like everywhere else in PyMuPDF.
  • Loading branch information
JorjMcKie authored and julian-smith-artifex-com committed Nov 14, 2022
1 parent 2e0b014 commit e876e81
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fitz/helper-devices.i
Expand Up @@ -493,7 +493,7 @@ jm_trace_text_span(fz_context *ctx, PyObject *out, fz_text_span *span, int type,
// make the span dictionary
PyObject *span_dict = PyDict_New();
DICT_SETITEMSTR_DROP(span_dict, "dir", JM_py_from_point(dir));
DICT_SETITEM_DROP(span_dict, dictkey_font, Py_BuildValue("s",fontname));
DICT_SETITEM_DROP(span_dict, dictkey_font, JM_EscapeStrFromStr(fontname));
DICT_SETITEM_DROP(span_dict, dictkey_wmode, PyLong_FromLong((long) span->wmode));
DICT_SETITEM_DROP(span_dict, dictkey_flags, PyLong_FromLong((long) fflags));
DICT_SETITEMSTR_DROP(span_dict, "bidi_lvl", PyLong_FromLong((long) span->bidi_level));
Expand Down

0 comments on commit e876e81

Please sign in to comment.