fix(meshchat): add error handling for ValueError in JSON responses and adjust script source policies based on request path

This commit is contained in:
Ivan
2026-04-23 04:31:08 -05:00
parent ff59f9d34e
commit d0f3199c70
+9 -1
View File
@@ -9068,6 +9068,8 @@ class ReticulumMeshChat:
"has_argos_cli": self.translator_handler.has_argos_cli,
},
)
except ValueError as e:
return web.json_response({"message": str(e)}, status=400)
except Exception as e:
return web.json_response(
{"message": str(e)},
@@ -9104,6 +9106,8 @@ class ReticulumMeshChat:
libretranslate_url=libretranslate_url,
)
return web.json_response(result)
except ValueError as e:
return web.json_response({"message": str(e)}, status=400)
except Exception as e:
return web.json_response(
{"message": str(e)},
@@ -11569,7 +11573,11 @@ class ReticulumMeshChat:
"'self'",
]
script_sources = ["'self'", "'unsafe-inline'", "'unsafe-eval'"]
path = request.path
if path.startswith("/reticulum-docs/") or path.startswith("/rnode-flasher/"):
script_sources = ["'self'", "'unsafe-inline'"]
else:
script_sources = ["'self'"]
style_sources = ["'self'", "'unsafe-inline'"]
if self.current_context and self.current_context.config: