refs #2285 improve failure conditions in EjecutarScript

unificar-endpoints
Natalia Serrano 2025-06-23 12:26:20 +02:00
parent 2feff97a91
commit 250de7a070
1 changed files with 8 additions and 1 deletions

View File

@ -358,7 +358,14 @@ class OpenGnSysWorker(ServerWorker):
"""
logger.debug('Processing script request')
# Decoding script
script = urllib.parse.unquote(base64.b64decode(post_params.get('script')).decode('utf-8'))
param_script = post_params.get('script')
if not param_script:
return {'op': 'error', 'err': 'Required parameter "script" is missing or empty'}
try:
b64decoded = base64.b64decode (param_script)
except Exception as e:
return {'op': 'error', 'err': f'Failed to decode base64: {e}'}
script = urllib.parse.unquote (b64decoded.decode ('utf-8'))
logger.debug('received script "{}"'.format(script))
if post_params.get('client', 'false') == 'false':