Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: LSDV-5486: Double encoding issue with file proxy urls #4663

Merged
merged 1 commit into from Aug 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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