fix(pages_v3): add ledmatrix- prefix fallback for plugin_id in web-ui route

Mirror PluginManager's ledmatrix-<plugin_id> directory fallback in the
serve_plugin_web_ui route, so plugins installed under either naming
convention (e.g. 'flights' on-disk as 'ledmatrix-flights') are served
correctly. Addresses coderabbit review comment.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Chuck
2026-05-30 20:46:04 -04:00
parent 98d4b3b55b
commit e873632f95

View File

@@ -129,6 +129,16 @@ def serve_plugin_web_ui(plugin_id, filename):
# Path containment guard — plugin_dir must be inside plugins base
_plugin_dir.relative_to(_plugins_base)
# Mirror PluginManager's ledmatrix- prefix fallback so both naming
# conventions (e.g. "flights" installed as "ledmatrix-flights") work.
if not _plugin_dir.exists():
_alt = (_plugins_base / f'ledmatrix-{plugin_id}').resolve()
try:
_alt.relative_to(_plugins_base)
_plugin_dir = _alt
except ValueError:
pass # alt path escaped base — ignore
web_ui_path = (_plugin_dir / 'web_ui' / filename).resolve()
# Second containment guard — must stay inside the plugin's web_ui dir
web_ui_path.relative_to(_plugin_dir / 'web_ui')