mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Base64-decode unicode values in Bytes parameters.
Fix wrong handling of strings in --setattr/--addattr/--delattr. These changes make it possible to use Bytes in --setattr/--addattr/ --delattr without errors. Fixes managing SSH keys on command-line https://fedorahosted.org/freeipa/ticket/754
This commit is contained in:
committed by
Rob Crittenden
parent
c00bf9e38a
commit
ca3f304110
@@ -101,6 +101,10 @@ a more detailed description for clarity.
|
||||
|
||||
import re
|
||||
import decimal
|
||||
import base64
|
||||
import csv
|
||||
from xmlrpclib import MAXINT, MININT
|
||||
|
||||
from types import NoneType
|
||||
from util import make_repr
|
||||
from text import _ as ugettext
|
||||
@@ -109,8 +113,6 @@ from errors import ConversionError, RequirementError, ValidationError
|
||||
from errors import PasswordMismatch
|
||||
from constants import NULLS, TYPE_ERROR, CALLABLE_ERROR
|
||||
from text import Gettext, FixMe
|
||||
import csv
|
||||
from xmlrpclib import MAXINT, MININT
|
||||
|
||||
|
||||
class DefaultFrom(ReadOnly):
|
||||
@@ -1440,6 +1442,14 @@ class Bytes(Data):
|
||||
length=self.length,
|
||||
)
|
||||
|
||||
def _convert_scalar(self, value, index=None):
|
||||
if isinstance(value, unicode):
|
||||
try:
|
||||
value = base64.b64decode(value)
|
||||
except TypeError:
|
||||
raise ConversionError(name=self.name, index=index, error=self.type_error)
|
||||
return super(Bytes, self)._convert_scalar(value, index)
|
||||
|
||||
|
||||
class Str(Data):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user