mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 23:12:21 -04:00
fix hasIllegal check, and associated unit test
This commit is contained in:
parent
6ed971cb6b
commit
99d82c1f2d
2 changed files with 8 additions and 4 deletions
|
@ -342,7 +342,7 @@ class MediaManager(object):
|
|||
def hasIllegal(self, str):
|
||||
# a file that couldn't be decoded to unicode is considered invalid
|
||||
if not isinstance(str, unicode):
|
||||
return False
|
||||
return True
|
||||
return not not re.search(self._illegalCharReg, str)
|
||||
|
||||
# Media syncing - bundling zip files to send to server
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
# coding: utf-8
|
||||
|
||||
import tempfile, os, time
|
||||
import tempfile
|
||||
import os
|
||||
import time
|
||||
|
||||
from shared import getEmptyDeck, testDir
|
||||
|
||||
|
||||
# copying files to media folder
|
||||
def test_add():
|
||||
d = getEmptyDeck()
|
||||
|
@ -100,8 +104,8 @@ def test_changes():
|
|||
|
||||
def test_illegal():
|
||||
d = getEmptyDeck()
|
||||
aString = "a:b|cd\\e/f\0g*h"
|
||||
good = "abcdefgh"
|
||||
aString = u"a:b|cd\\e/f\0g*h"
|
||||
good = u"abcdefgh"
|
||||
assert d.media.stripIllegal(aString) == good
|
||||
for c in aString:
|
||||
bad = d.media.hasIllegal("somestring"+c+"morestring")
|
||||
|
|
Loading…
Reference in a new issue