-
Notifications
You must be signed in to change notification settings - Fork 45
fix: trim file content before comparison in getUrl to fix string matching bug #768
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -254,11 +254,17 @@ bool Utils::isDpkgLocked() | |
|
|
||
| QString Utils::getUrl() | ||
| { | ||
| // ~/url 文件用于切换驱动查询的环境地址: | ||
| // - 文件不存在或不可读时,默认使用生产环境 URL(安全默认) | ||
| // - 文件内容为 "true" 时,使用生产环境 URL | ||
| // - 文件内容为其他值时,使用预生产环境 URL | ||
| // 该设计意图与客户端 commontools.cpp 中 CommonTools::getUrl() 保持一致 | ||
| QFile file(QDir::homePath() + "/url"); | ||
| if (!file.open(QIODevice::ReadOnly)) { | ||
| return "https://driver.uniontech.com/api/v1/drive/search"; | ||
| } | ||
| QString info = file.readAll(); | ||
| // trimmed() 去除首尾空白和换行符,确保 "true\n" 等内容能正确匹配 "true" | ||
| QString info = file.readAll().trimmed(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue (broader_impact): The server now treats Triggers: When Suggested fix: Apply the same trimming behavior in |
||
| if ("true" == info) { | ||
| return "https://driver.uniontech.com/api/v1/drive/search"; | ||
| } else { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: The new comment claims this implementation’s design intent remains consistent with
CommonTools::getUrl(), butCommonTools::getUrl()does not calltrimmed()and has different behavior for whitespace-terminated values. The comment falsely documents cross-component consistency and can mislead future maintainers into assuming the client has the same fix.Suggested fix: Update the client implementation as well, or change the comment to state that the implementations currently differ.