From 99d82c1f2dbb9358a987e2293a78f7fa9ab11ecf Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Tue, 26 Nov 2013 03:19:11 +0900 Subject: [PATCH] fix hasIllegal check, and associated unit test --- anki/media.py | 2 +- tests/test_media.py | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/anki/media.py b/anki/media.py index 822982050..716da58ff 100644 --- a/anki/media.py +++ b/anki/media.py @@ -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 diff --git a/tests/test_media.py b/tests/test_media.py index 4eb673768..e47ac8454 100644 --- a/tests/test_media.py +++ b/tests/test_media.py @@ -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")