fix hasIllegal check, and associated unit test

This commit is contained in:
Damien Elmes 2013-11-26 03:19:11 +09:00
parent 6ed971cb6b
commit 99d82c1f2d
2 changed files with 8 additions and 4 deletions

View file

@ -342,7 +342,7 @@ class MediaManager(object):
def hasIllegal(self, str): def hasIllegal(self, str):
# a file that couldn't be decoded to unicode is considered invalid # a file that couldn't be decoded to unicode is considered invalid
if not isinstance(str, unicode): if not isinstance(str, unicode):
return False return True
return not not re.search(self._illegalCharReg, str) return not not re.search(self._illegalCharReg, str)
# Media syncing - bundling zip files to send to server # Media syncing - bundling zip files to send to server

View file

@ -1,8 +1,12 @@
# coding: utf-8 # coding: utf-8
import tempfile, os, time import tempfile
import os
import time
from shared import getEmptyDeck, testDir from shared import getEmptyDeck, testDir
# copying files to media folder # copying files to media folder
def test_add(): def test_add():
d = getEmptyDeck() d = getEmptyDeck()
@ -100,8 +104,8 @@ def test_changes():
def test_illegal(): def test_illegal():
d = getEmptyDeck() d = getEmptyDeck()
aString = "a:b|cd\\e/f\0g*h" aString = u"a:b|cd\\e/f\0g*h"
good = "abcdefgh" good = u"abcdefgh"
assert d.media.stripIllegal(aString) == good assert d.media.stripIllegal(aString) == good
for c in aString: for c in aString:
bad = d.media.hasIllegal("somestring"+c+"morestring") bad = d.media.hasIllegal("somestring"+c+"morestring")