mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Fixed #12397 -- allow safe_join to work with the root file system path, which means you can have your root template or file upload path at this location. You almost certainly don't want to do this, except in *very* limited sandboxed situations.
This commit is contained in:
parent
3a10bcc917
commit
b865009d41
3 changed files with 32 additions and 7 deletions
21
tests/regressiontests/utils/os_utils.py
Normal file
21
tests/regressiontests/utils/os_utils.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
from django.utils import unittest
|
||||
from django.utils._os import safe_join
|
||||
|
||||
|
||||
class SafeJoinTests(unittest.TestCase):
|
||||
def test_base_path_ends_with_sep(self):
|
||||
self.assertEqual(
|
||||
safe_join("/abc/", "abc"),
|
||||
"/abc/abc",
|
||||
)
|
||||
|
||||
def test_root_path(self):
|
||||
self.assertEqual(
|
||||
safe_join("/", "path"),
|
||||
"/path",
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
safe_join("/", ""),
|
||||
"/",
|
||||
)
|
|
@ -21,6 +21,7 @@ from .http import TestUtilsHttp
|
|||
from .ipv6 import TestUtilsIPv6
|
||||
from .jslex import JsToCForGettextTest, JsTokensTest
|
||||
from .module_loading import CustomLoader, DefaultLoader, EggLoader
|
||||
from .os_utils import SafeJoinTests
|
||||
from .regex_helper import NormalizeTests
|
||||
from .simplelazyobject import TestUtilsSimpleLazyObject
|
||||
from .termcolors import TermColorTests
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue