Commits

Yuya Nishihara  committed 519b49e

qscilib: check null bytes when reading file as in RejectsDialog

  • Participants
  • Parent commits 732c546
  • Branches stable

Comments (0)

Files changed (1)

File tortoisehg/hgqt/qscilib.py

                             _('Could not open the specified file for reading.'),
                             f.errorString(), parent=editor)
         return False
+    earlybytes = f.read(4096)
+    if '\0' in earlybytes:
+        qtlib.WarningMsgBox(_('Unable to read file'),
+                            _('This appears to be a binary file.'),
+                            parent=editor)
+        return False
+
+    f.seek(0)
     if not editor.read(f):
         qtlib.WarningMsgBox(_('Unable to read file'),
                             _('An error occurred while reading the file.'),