diff options
| author | Florian Apolloner <florian@apolloner.eu> | 2021-12-14 12:38:28 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-12-14 20:19:44 +0100 |
| commit | e1d673c373a7d032060872b690a92fc95496612e (patch) | |
| tree | 2bebd60e8cc58029761fd1b55cfc8f3598be6676 /django/utils | |
| parent | 5d9c512e5b42e1c686300c214453bf0b820d7326 (diff) | |
Fixed unescape_string_literal() crash on empty strings.
Diffstat (limited to 'django/utils')
| -rw-r--r-- | django/utils/text.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/django/utils/text.py b/django/utils/text.py index 3e4199a1d9..fa337650af 100644 --- a/django/utils/text.py +++ b/django/utils/text.py @@ -375,7 +375,7 @@ def unescape_string_literal(s): >>> unescape_string_literal("'\'ab\' c'") "'ab' c" """ - if s[0] not in "\"'" or s[-1] != s[0]: + if not s or s[0] not in "\"'" or s[-1] != s[0]: raise ValueError("Not a string literal: %r" % s) quote = s[0] return s[1:-1].replace(r'\%s' % quote, quote).replace(r'\\', '\\') |
