Names with an apostrophe break the XPath queries in RtLocks, RtCounters, and RtCounter
还没有人认领这个 Issue。
评估
调研方向
从 src/main/java/co/stateful/RtLocks.java、RtCounter.java 和 RtCounters.java 开始,issue 在这些文件中展示了三个会插入名称的 XPath 表达式。阅读这些方法如何构建和执行查询,然后在这三个位置统一采用一种安全的 XPath 字面量处理方法。完成标准是:对于列出的操作,包含任一种或两种引号的名称都能正常工作,同时不改变所选项目。
由索引模型根据 Issue 内容生成。
描述
A lock or counter name that contains a single quote makes the XPath expression invalid, so the call fails instead of finding the item.
The name is pasted straight into a single-quoted XPath literal:
// src/main/java/co/stateful/RtLocks.java:53
.nodes(String.format("/page/locks/lock[name='%s']", name))
// src/main/java/co/stateful/RtCounter.java:93
"/page/counters/counter[name='%s']/links/link[@rel='%s']/@href"
// src/main/java/co/stateful/RtCounters.java (delete)
"/page/counters/counter[name='%s']/links/link[@rel='delete']/@href"
Take locks.exists("it's"): the expression becomes /page/locks/lock[name='it's'], which is malformed XPath, so exists throws instead of returning a boolean. The same happens in counter.set(...), counter.incrementAndGet(...), and counters.delete("it's"). A name like x' or '1'='1 changes the query and may select another item.
Fix: build the XPath literal safely. Either pass the name as an XPath variable, or write a small helper that wraps the value in double quotes when it has a single quote, and uses concat(...) when it has both kinds of quotes. Use it in all three places.
- 主要语言
- Java
- 星标
- 10
- 派生
- 3
- 平均合并
- 4 小时 33 分钟
- 30 天内合并 PR
- 7
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
sttc/java-sdk 的其他 Issue
-
MkCounter.name() returns the class name instead of the counter name, and MkCounters drops the name可能已有人在做 @yegor256 于 6 天前认领。 未关闭bug
-
wontfix
难度 1/5 1 小时以内 新手友好度 35/100
相似的 Issue
-
physical
难度 2/5 1-3 小时 新手友好度 74/100
antonyrag/ragleap-core#1339 ·
-
Bug
难度 2/5 1-3 小时 新手友好度 72/100
rezelyn/Wathe-Extended#116 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
langchain4j/langchain4j#7068 ·
维护者通常 1 天内回复
-
Mend: dependency security vulnerability untriaged
难度 2/5 1-3 小时 新手友好度 73/100
opensearch-project/k-NN#3693 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
OneBusAway/maglev#2026 ·
维护者通常 2 天内回复