Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

fixes #91

jonaswinklerdefa80d05ac2
diff --git a/src/documents/serialisers.py b/src/documents/serialisers.py
index 600645061..db0e610d1 100644
--- a/src/documents/serialisers.py
+++ b/src/documents/serialisers.py
@@ -1,6 +1,5 @@
import magic
from django.utils.text import slugify
-from pathvalidate import validate_filename, ValidationError
from rest_framework import serializers
from rest_framework.fields import SerializerMethodField
@@ -179,12 +178,6 @@ class PostDocumentSerializer(serializers.Serializer):
)
def validate_document(self, document):
-
- try:
- validate_filename(document.name)
- except ValidationError:
- raise serializers.ValidationError("Invalid filename.")
-
document_data = document.file.read()
mime_type = magic.from_buffer(document_data, mime=True)
diff --git a/src/documents/tests/test_api.py b/src/documents/tests/test_api.py
index 572667406..ab1716366 100644
--- a/src/documents/tests/test_api.py
+++ b/src/documents/tests/test_api.py
@@ -403,16 +403,6 @@ class TestDocumentApi(DirectoriesMixin, APITestCase):
self.assertEqual(response.status_code, 400)
m.assert_not_called()
- @mock.patch("documents.views.async_task")
- @mock.patch("documents.serialisers.validate_filename")
- def test_upload_invalid_filename(self, validate_filename, async_task):
- validate_filename.side_effect = ValidationError()
- with open(os.path.join(os.path.dirname(__file__), "samples", "simple.pdf"), "rb") as f:
- response = self.client.post("/api/documents/post_document/", {"document": f})
- self.assertEqual(response.status_code, 400)
-
- async_task.assert_not_called()
-
@mock.patch("documents.views.async_task")
def test_upload_with_title(self, async_task):
with open(os.path.join(os.path.dirname(__file__), "samples", "simple.pdf"), "rb") as f: