Skip to content
Snippets Groups Projects
Commit 7e129760 authored by Bastien Abadie's avatar Bastien Abadie
Browse files

Merge branch 'fix-image-paths' into 'master'

Fix double URL-encoded image paths

See merge request !202
parents d66b1576 e7f4a3aa
No related branches found
No related tags found
1 merge request!202Fix double URL-encoded image paths
# Generated by Django 2.1 on 2019-01-31 14:43
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('images', '0006_unique_server_url'),
]
operations = [
migrations.AlterField(
model_name='image',
name='path',
field=models.TextField(),
),
]
......@@ -84,7 +84,7 @@ class Image(IndexableModel):
A document image
"""
server = models.ForeignKey(ImageServer, on_delete=models.CASCADE, related_name='images')
path = models.URLField()
path = models.TextField()
width = models.PositiveIntegerField(default=0)
height = models.PositiveIntegerField(default=0)
status = EnumField(ImageStatus, default=ImageStatus.Unchecked, max_length=50)
......
......@@ -143,3 +143,15 @@ class TestImageServer(FixtureTestCase):
server = ImageServer.objects.create(name='dummy', url='http://test/iiif')
image = server.find_image('https://test/iiif/dog.jpg', width=800, height=600)
self.assertEqual(image.status, ImageStatus.Error) # connection error, no exception
class TestImage(FixtureTestCase):
def test_path_not_encoded(self):
"""
Assert that an image's path is not URL encoded when created
This can yield to images with URLs such as http://.../test%34test to be encoded as http://.../test%2534test
"""
img = Image.objects.create(server=self.imgsrv, path='!#%:+*')
img.refresh_from_db()
self.assertEqual(img.path, '!#%:+*')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment