Luligu/matterbridge

Frontend appends trailing slash to plugin configUrl, corrupting query strings (since 3.9.2)

开放

#579 创建于 2026年7月11日

 (2 条评论) (0 个反应) (1 位负责人)TypeScript (53 个派生)auto 404
help wanted

仓库指标

星标
 (938 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

Since 3.9.2, the frontend's handleConfigUrl normalizes a device's configUrl before loading it in the plugin-frontend iframe (introduced with the Ingress base-path support):

const t = ${basePath}${configUrl.replace(/^\.?\//, '')};
const n = t.endsWith('/') ? t : ${t}/; // ← appends '/' blindly

The trailing-slash normalization ignores query strings. A plugin configUrl like:

/plugins/matterbridge-mqtt-devices/?device=temp1 becomes: /plugins/matterbridge-mqtt-devices/?device=temp1/

The slash lands inside the query value, so the plugin page receives device=temp1/, its GET /plugins/<name>/api/config?device=temp1%2F lookup fails, and onFetch returning undefined produces a 404 — the config page renders empty. This worked in 3.9.1, which passed configUrl to the iframe verbatim.

Steps to reproduce

Install a plugin whose device configUrl carries a query string, e.g. matterbridge-mqtt-devices (/plugins/matterbridge-mqtt-devices/?device=<id>). Open the device's config page from the Devices view on Matterbridge ≥3.9.2. The plugin frontend loads, but the query parameter arrives with a trailing / appended. Expected behavior The trailing slash should only be applied to the path portion, e.g.:

const url = new URL(t, window.location.origin);
if (!url.pathname.endsWith('/')) url.pathname += '/';

Reported downstream: hobbyquaker/matterbridge-mqtt-devices#2 (worked around plugin-side in 0.10.4 by stripping trailing slashes from the query value).

贡献者指南