A reversed PatternValidator renders a pattern attribute that rejects the input the validator accepts
维护者通常 1 天内回复
@reiern70 已经在做这个了。
开始于 2026年11月12日。
评估
调研方向
The pattern attribute is written in AbstractTextComponent#onComponentTag and HTML5Attributes#onInput, both in wicket-core. Start by reading how those two places iterate over the PatternValidator instances, and add an isReverse() getter to PatternValidator. Done when a reversed validator no longer produces a pattern attribute in the rendered <input>, and the existing tests for HTML5 attributes still pass.
由索引模型根据 Issue 内容生成。
描述
Affects: 11.0.0 and current master, on every text component. 10.x when the HTML5Attributes behavior is added.
Component: wicket-core, AbstractTextComponent, HTML5Attributes, PatternValidator
What happens
A text field with a reversed PatternValidator:
field.add(new PatternValidator("[a-z]+").setReverse(true));
renders:
<input type="text" ... pattern="[a-z]+">
The validator means "input that matches [a-z]+ is invalid". The pattern attribute tells the browser the opposite: input that does not match is invalid. A non-empty value can't pass both checks:
123is valid on the server, but the browser blocks the submit (patternMismatch, checked in Chrome and Firefox).abcpasses the browser, and the server rejects it.
Only an empty value gets through, because neither check applies to it.
Cause
AbstractTextComponent#onComponentTag (and HTML5Attributes#onInput) copies the pattern of every PatternValidator into the pattern attribute and ignores the reverse flag. PatternValidator has no getter for that flag, so the renderers can't see it.
Fix proposed
Render no pattern attribute for a reversed validator, and leave the check to the server. An HTML pattern can't express "must not match" reliably for an arbitrary Java pattern. This needs a public getter, PatternValidator#isReverse().
Workaround
Remove the attribute with a behavior added after the validator:
field.add(new Behavior() {
@Override
public void onComponentTag(Component component, ComponentTag tag) {
tag.remove("pattern");
}
});
Found while fixing #1884.
- 主要语言
- Java
- 星标
- 800
- 派生
- 437
- 平均合并
- 21 小时 36 分钟
- 30 天内合并 PR
- 167
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
apache/wicket 的其他 Issue
-
PropertyResolver fails on JDK classes with a non-public field named like the property可能已有人在做 @vaibhavgupta443 今天认领。 未关闭good first issue
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复
-
Stop the autocomplete from accumulating request parameters while typing可能已有人在做 @aryankalantri 今天认领。 未关闭good first issue
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
Validate the report-uri value given to CSPHeaderConfiguration#reportBack可能已有人在做 @AzizOuertani 于 3 天前认领。 未关闭good first issue
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 70/100
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 66/100
jenkinsci/user-guide-ai-chatbot-plugin#132 ·
维护者通常 6 天内回复
-
account assessment course feature lecture
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 1 天内回复
-
bug db/dameng user-priority/P2
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
app:learninggoalhub enhancement good first issue
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100