mirror of
https://github.com/ankitects/anki.git
synced 2025-12-13 23:00:58 -05:00
ensure user doesn't try to export into data folder
https://anki.tenderapp.com/discussions/ankidesktop/39008-export-path-accidentally-set-to-collectionmedia-possible-damage
This commit is contained in:
parent
06dee0ef08
commit
f71484a444
1 changed files with 6 additions and 1 deletions
|
|
@ -1,6 +1,8 @@
|
||||||
# Copyright: Ankitects Pty Ltd and contributors
|
# Copyright: Ankitects Pty Ltd and contributors
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
|
|
@ -15,7 +17,7 @@ from aqt.utils import checkInvalidFilename, getSaveFile, showWarning, tooltip
|
||||||
|
|
||||||
|
|
||||||
class ExportDialog(QDialog):
|
class ExportDialog(QDialog):
|
||||||
def __init__(self, mw, did: Optional[int] = None, cids: Optional[List[int]] = None):
|
def __init__(self, mw: aqt.main.AnkiQt, did: Optional[int] = None, cids: Optional[List[int]] = None):
|
||||||
QDialog.__init__(self, mw, Qt.Window)
|
QDialog.__init__(self, mw, Qt.Window)
|
||||||
self.mw = mw
|
self.mw = mw
|
||||||
self.col = mw.col
|
self.col = mw.col
|
||||||
|
|
@ -118,6 +120,9 @@ class ExportDialog(QDialog):
|
||||||
return
|
return
|
||||||
if checkInvalidFilename(os.path.basename(file), dirsep=False):
|
if checkInvalidFilename(os.path.basename(file), dirsep=False):
|
||||||
continue
|
continue
|
||||||
|
if os.path.commonprefix([self.mw.pm.base, file]) == self.mw.pm.base:
|
||||||
|
showWarning("Please choose a different export location.")
|
||||||
|
continue
|
||||||
break
|
break
|
||||||
self.hide()
|
self.hide()
|
||||||
if file:
|
if file:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue