Skip to content

fix(luci-base): 修复 dnsmasq 编译选项正则匹配缺陷导致前端隐藏 DHCP-Options 的问题 - #417

Merged
coolsnowwolf merged 1 commit into
coolsnowwolf:openwrt-25.12from
EluneAdore:patch-1
Sep 13, 2026
Merged

coolsnowwolf merged 1 commit into
coolsnowwolf:openwrt-25.12from
EluneAdore:patch-1

Conversation

@EluneAdore

Copy link
Copy Markdown
Contributor

问题分析

modules/luci-base/root/usr/share/rpcd/ucode/luci 中探测 dnsmasq 功能时,原正则采用了: match(fd.read('all'), /^Compile time options: (.+)$/s)

由于 dnsmasq --version 的第一行输出是版权与版本声明(例如 Dnsmasq version 2.90...),Compile time options: 实际在第二行。原正则中的 ^ 锚定在全文开头,导致 m 永远匹配失败(返回 null)。 这导致 result.dnsmasq 未能生成,前端 L.hasSystemFeature('dnsmasq') 恒为 false,使得 Web 界面【网络 -> 接口 -> LAN -> DHCP 服务器】中的【DHCP 选项】(DHCP-Options)、【强制】等关键输入框被错误隐藏。

修复方案

移除开头的全文锚定 ^,使用 /Compile time options: ([^\n]+)/ 捕获该行选项,确保 result.dnsmasq 正常注入,恢复 Web 界面 DHCP 选项的正常渲染与配置。

  • This PR is not from my main or master branch 💩, but a separate branch ✅
  • Each commit has a valid ✒️ Signed-off-by: <my@email.address> row (via git commit --signoff)
  • Each commit and PR title has a valid 📝 <package name>: title first line subject for packages
  • Incremented 🆙 any PKG_VERSION in the Makefile
  • Tested on: (architecture, openwrt version, browser) ✅
  • ( Preferred ) Mention: @ the original code author for feedback
  • ( Preferred ) Screenshot or mp4 of changes:
  • ( Optional ) Closes: e.g. openwrt/luci#issue-number
  • ( Optional ) Depends on: e.g. openwrt/packages#pr-number in sister repo
  • Description: (describe the changes proposed in this PR)

### 问题分析
在 `modules/luci-base/root/usr/share/rpcd/ucode/luci` 中探测 dnsmasq 功能时,原正则采用了:
`match(fd.read('all'), /^Compile time options: (.+)$/s)`

由于 `dnsmasq --version` 的第一行输出是版权与版本声明(例如 `Dnsmasq version 2.90...`),`Compile time options:` 实际在第二行。原正则中的 `^` 锚定在全文开头,导致 `m` 永远匹配失败(返回 `null`)。
这导致 `result.dnsmasq` 未能生成,前端 `L.hasSystemFeature('dnsmasq')` 恒为 `false`,使得 Web 界面【网络 -> 接口 -> LAN -> DHCP 服务器】中的【DHCP 选项】(DHCP-Options)、【强制】等关键输入框被错误隐藏。

### 修复方案
移除开头的全文锚定 `^`,使用 `/Compile time options: ([^\n]+)/` 捕获该行选项,确保 `result.dnsmasq` 正常注入,恢复 Web 界面 DHCP 选项的正常渲染与配置。
@coolsnowwolf
coolsnowwolf merged commit 6409fcb into coolsnowwolf:openwrt-25.12 Sep 13, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants