Lines 31-36
Link Here
|
31 |
# /usr/share/common-licenses/AGPL-3; if not, see |
31 |
# /usr/share/common-licenses/AGPL-3; if not, see |
32 |
# <http://www.gnu.org/licenses/>. |
32 |
# <http://www.gnu.org/licenses/>. |
33 |
|
33 |
|
|
|
34 |
import re |
35 |
|
34 |
from univention.lib.i18n import Translation |
36 |
from univention.lib.i18n import Translation |
35 |
from univention.management.console.modules import Base |
37 |
from univention.management.console.modules import Base |
36 |
from univention.management.console.protocol.definitions import * |
38 |
from univention.management.console.protocol.definitions import * |
Lines 86-92
Link Here
|
86 |
return False |
88 |
return False |
87 |
|
89 |
|
88 |
def add( self, request ): |
90 |
def add( self, request ): |
89 |
# does the same as put |
91 |
if isinstance( request.options, ( list, tuple ) ): |
|
|
92 |
for _var in request.options: |
93 |
try: |
94 |
var = _var['object'] |
95 |
key = var['key'] |
96 |
ucrinfo = ConfigRegistryInfo(registered_only=False) |
97 |
if ucrinfo.get_variable(key) is not None: |
98 |
request.status = BAD_REQUEST_INVALID_ARGS |
99 |
self.finished(request.id, False, message = _('The key %s is already in use for an existing UCR variable.') % key) |
100 |
except KeyError: |
101 |
# handle the case that no key is given for an UCR variable entry |
102 |
request.status = BAD_REQUEST_INVALID_OPTS |
103 |
self.finished(request.id, False, message = _('Invalid UCR variable entry, the properties "key" and "value" need to be specified.')) |
104 |
return |
105 |
else: |
106 |
request.status = BAD_REQUEST_INVALID_OPTS |
107 |
self.finished(request.id, False) |
108 |
|
90 |
self.put( request ) |
109 |
self.put( request ) |
91 |
|
110 |
|
92 |
def put( self, request ): |
111 |
def put( self, request ): |
Lines 99-104
Link Here
|
99 |
var = _var['object'] |
118 |
var = _var['object'] |
100 |
value = var['value'] or '' |
119 |
value = var['value'] or '' |
101 |
key = var['key'] |
120 |
key = var['key'] |
|
|
121 |
if not re.match('^[a-zA-Z0-9/._-]+$', key): |
122 |
success = False |
123 |
request.status = BAD_REQUEST_INVALID_ARGS |
124 |
message = _( 'A valid key must contain at least one character and can only contain letters, numerals, and "/", ".", "_", "-".' ) |
125 |
break |
102 |
if self.is_readonly( key ): |
126 |
if self.is_readonly( key ): |
103 |
success = False |
127 |
success = False |
104 |
message = _( 'The UCR variable %s is read-only and can not be changed!' ) % key |
128 |
message = _( 'The UCR variable %s is read-only and can not be changed!' ) % key |