Skip to content

Commit

Permalink
fix: LSDV-5486: Double encoding issue with file proxy urls (#4663)
Browse files Browse the repository at this point in the history
  • Loading branch information
bmartel committed Aug 21, 2023
1 parent 369a846 commit 9798825
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions label_studio/tasks/models.py
Expand Up @@ -7,8 +7,9 @@
import datetime
import numbers
import time
import base64

from urllib.parse import urljoin, quote
from urllib.parse import urljoin

from django.conf import settings
from django.contrib.auth.models import AnonymousUser
Expand Down Expand Up @@ -249,7 +250,11 @@ def resolve_uri(self, task_data, project):
protected_data = {}
for key, value in task_data.items():
if isinstance(value, str) and string_is_url(value):
path = reverse('projects-file-proxy', kwargs={'pk': project.pk}) + '?url=' + quote(value)
path = (
reverse('projects-file-proxy', kwargs={'pk': project.pk})
+ '?url='
+ base64.urlsafe_b64encode(value.encode()).decode()
)
value = urljoin(settings.HOSTNAME, path)
protected_data[key] = value
return protected_data
Expand Down

0 comments on commit 9798825

Please sign in to comment.