fix: fix is_safe_url and urlquote warnings (#33041)

* fix: fix is_safe_url and urlquote warnings
* fix: replace urlquote with quote
This commit is contained in:
Usama Sadiq
2023-08-17 16:59:23 +05:00
committed by GitHub
parent f20b7ec985
commit 59782fa625
7 changed files with 17 additions and 16 deletions

View File

@@ -9,8 +9,8 @@ from unittest.mock import Mock, patch
from django.http import Http404
from django.test.client import RequestFactory
from django.utils import http
from pytz import UTC
from urllib.parse import quote
import cms.djangoapps.contentstore.views.component as views
from cms.djangoapps.contentstore.tests.test_libraries import LibraryTestCase
@@ -67,10 +67,10 @@ class ContainerPageTestCase(StudioPageTestCase, LibraryTestCase):
'<a href="/course/{course}{subsection_parameters}">Lesson 1</a>'
).format(
course=re.escape(str(self.course.id)),
section_parameters=re.escape('?show={}'.format(http.urlquote(
section_parameters=re.escape('?show={}'.format(quote(
str(self.chapter.location).encode()
))),
subsection_parameters=re.escape('?show={}'.format(http.urlquote(
subsection_parameters=re.escape('?show={}'.format(quote(
str(self.sequential.location).encode()
))),
),
@@ -97,7 +97,7 @@ class ContainerPageTestCase(StudioPageTestCase, LibraryTestCase):
).format(
course=re.escape(str(self.course.id)),
unit_parameters=re.escape(str(self.vertical.location)),
subsection_parameters=re.escape('?show={}'.format(http.urlquote(
subsection_parameters=re.escape('?show={}'.format(quote(
str(self.sequential.location).encode()
))),
),

View File

@@ -3,7 +3,7 @@ Unit tests for helpers.py.
"""
from django.utils import http
from urllib.parse import quote
from cms.djangoapps.contentstore.tests.utils import CourseTestCase
from xmodule.modulestore.tests.factories import BlockFactory, LibraryFactory # lint-amnesty, pylint: disable=wrong-import-order
@@ -27,7 +27,7 @@ class HelpersTestCase(CourseTestCase):
display_name="Week 1")
self.assertEqual(
xblock_studio_url(chapter),
f'{course_url}?show={http.urlquote(str(chapter.location).encode())}'
f'{course_url}?show={quote(str(chapter.location).encode())}'
)
# Verify sequential URL
@@ -35,7 +35,7 @@ class HelpersTestCase(CourseTestCase):
display_name="Lesson 1")
self.assertEqual(
xblock_studio_url(sequential),
f'{course_url}?show={http.urlquote(str(sequential.location).encode())}'
f'{course_url}?show={quote(str(sequential.location).encode())}'
)
# Verify unit URL