Cleanup: simplify the link regex in Email.extractLink

未关闭 适合新手
#275 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
78/100
Issue 类型
重构
描述清晰度
描述清楚
活跃度
活跃
技术栈
java
领域
testing-qa

调研方向

该 regex 位于 src/main/java/com/seleniumboot/email/Email.java 的第 70 行,在 Email.extractLink(...) 内部。先阅读现有的 extractLink 测试,然后重写该模式,使任意两个部分都不能匹配相同的字符,同时保留引号风格、属性顺序和大小写不敏感性。当现有测试通过、一个包含大量 <a 标签且无匹配的长正文的新测试能快速结束,并且 mvn test 通过时即完成。

由索引模型根据 Issue 内容生成。

描述

good first issue

Part of the cleanup cycle from #251. SonarCloud rule java:S8786 flags the link-matching regex in Email.extractLink(...) for possible super-linear backtracking. Email bodies come from outside, so this one is worth fixing.

Where: src/main/java/com/seleniumboot/email/Email.java, line 70:

"<a[^>]+href=[\"']([^\"']+)[\"'][^>]*>(.*?)</a>"

The [^>]+ before href can overlap with the attribute that follows it.

Fix: rewrite it so no two parts can match the same characters. For example, match <a\b, then attributes that don't start with href, then the href. Or use a possessive / atomic group. Keep the behaviour: double or single quotes, other attributes before or after href, nested tags in the link text, case-insensitive.

Done when: the existing extractLink tests still pass, a new test covers a long body with many <a tags and no match (it must finish quickly), SonarCloud no longer flags the line, and mvn test passes.

主要语言
Java
星标
12
派生
6
平均合并
8 小时 58 分钟
30 天内合并 PR
63

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

seleniumboot/selenium-boot 的其他 Issue

查看 seleniumboot/selenium-boot 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。