Avoid server error caused by UnicodeDecodeError

Sometimes b32decode may generate data which can't be decoded.
Ignore UnicodeDecodeError so that a few other formats can be tried.

Closes-bug: #2043572
Change-Id: I5d978e8eb3931a218b1946625baa28aa23890cd6
(cherry picked from commit e1b7aceff9)
(cherry picked from commit d28c06a525)
This commit is contained in:
sehun.jeong 2023-11-21 15:49:11 +09:00 committed by Goutham Pacha Ravi
parent 90e74cca3e
commit ea689f5a66
2 changed files with 6 additions and 1 deletions

View File

@ -124,7 +124,7 @@ def transform_dashed_name(name):
try:
return base64.b32decode(
name.replace('_', '=').upper().encode()).decode()
except binascii.Error:
except (binascii.Error, UnicodeDecodeError):
if re.search(r'^[a-z_\d]+$', name):
return name # leave as-is names without dashes and capitals
else:

View File

@ -0,0 +1,5 @@
---
fixes:
- |
Fixed error in share creation caused by internal UnicodeDecodeError.
`Launchpad bug #2043572 <https://bugs.launchpad.net/manila-ui/+bug/2043572>`_