Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:在作业查询接口加入了正则表达式的格式检查,若格式错误则返回400状态码及正则表达式不合法信息 #174

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

wxy3265
Copy link

@wxy3265 wxy3265 commented Nov 3, 2024

Java原生的正则表达式解析工具方法Pattern.compile()可以按照正则表达式解析字符串,该方法在正则表达式不合法时会抛出PatternSyntaxException。因此在按照正则表达式查询之前尝试调用该方法,若捕获到PatternSyntaxException异常说明解析失败,即表达式不合法,返回包括400状态码和错误信息的fail结果。

@@ -272,6 +272,7 @@ class CopilotService(

// 标题、描述、神秘代码
if (!request.document.isNullOrBlank()) {
Pattern.compile(request.document)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

java 支持的 regex 与 mongodb 所支持的并不相同,有没有更好的检测方法

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