Merge branch 'bug-666837-add_+_symbol_to_modules'

This commit is contained in:
Sean McArthur 2011-09-20 15:02:51 -05:00
Родитель c03d7cbaa2 a5d9a8a721
Коммит 174a210ebb
3 изменённых файлов: 13 добавлений и 5 удалений

Просмотреть файл

@ -83,6 +83,9 @@ TYPE_CHOICES = (
)
FILENAME_RE = r'[^a-zA-Z0-9=!@#\$%\^&\(\)\+\-_\/\.]+'
class PackageRevision(BaseModel):
"""
contains data which may be changed and rolled back
@ -1934,7 +1937,7 @@ class Module(BaseModel):
self.filename = self.filename[:first_period]
# remove illegal characters from filename
self.filename = re.sub('[^a-zA-Z0-9=!@#\$%\^&\(\)\+\-_\/\.]+', '-',
self.filename = re.sub(FILENAME_RE, '-',
self.filename)
self.filename = re.sub('\/{2,}', '/', self.filename)
self.filename = re.sub('^\/', '', self.filename)
@ -2095,7 +2098,7 @@ class Attachment(BaseModel):
return self
def clean(self):
self.filename = pathify(self.filename)
self.filename = re.sub(FILENAME_RE, '-', self.filename)
if self.ext:
self.ext = alphanum(self.ext)

Просмотреть файл

@ -408,12 +408,12 @@ class TestViews(TestCase):
revision = self.add_one(filename='^you*()"[]"are-_crazy')
att = revision.attachments.all()[0]
eq_(att.filename, '-you-are-_crazy')
eq_(att.filename, '^you-()-are-_crazy')
revision.attachment_remove(att)
revision = self.add_one(filename='"><a href="">test')
att = revision.attachments.all()[0]
eq_(att.filename, '-a-href-test')
eq_(att.filename, '-a-href=-test')
revision.attachment_remove(att)
revision = self.add_one(filename='template.html.js')
@ -433,6 +433,11 @@ class TestViews(TestCase):
eq_(att.ext, 'ahref')
revision.attachment_remove(att)
revision = self.add_one(filename='data+test.js')
att = revision.attachments.all()[0]
eq_(att.filename, 'data+test')
revision.attachment_remove(att)
def get_revision_from_response(self, response):
return self.package.revisions.filter(
revision_number=response['revision_number']).get()

Просмотреть файл

@ -453,7 +453,7 @@ var Sidebar = new Class({
// remove janky characters from filenames
// (from promptAttachment)
filename = filename.replace(/[^a-zA-Z0-9\-_\/\.]+/g, '-');
filename = filename.replace(/[^a-zA-Z0-9=!@#\$%\^&\(\)\+\-_\/\.]+/g, '-');
filename = filename.replace(/\/{2,}/g, '/');
if (filename[filename.length-1] == '/') {