Skip to content

Fix:pdf url access error#21

Merged
deepin-bot[bot] merged 2 commits intolinuxdeepin:develop/eaglefrom
LiHua000:develop/eagle
Nov 24, 2025
Merged

Fix:pdf url access error#21
deepin-bot[bot] merged 2 commits intolinuxdeepin:develop/eaglefrom
LiHua000:develop/eagle

Conversation

@LiHua000
Copy link

Cannot handle URLs longer than 256 characters.

bug: https://pms.uniontech.com/bug-view-341615.html

@github-actions
Copy link

TAG Bot

TAG: 1.0.3
EXISTED: no
DISTRIBUTION: stable

@deepin-ci-robot
Copy link

deepin pr auto review

我来对这个 diff 进行审查:

  1. 语法逻辑:
  • 代码修改的语法是正确的,将 uri 缓冲区大小从 256 增加到 2048,并相应地更新了 FPDFAction_GetURIPath 函数的参数。
  • 变量名 "lenth" 存在拼写错误,应该是 "length",但这不是本次修改的内容。
  1. 代码质量:
  • 这个修改提高了代码的健壮性,因为 256 字节的缓冲区对于现代 URL 来说可能太小了。
  • 建议使用常量定义缓冲区大小,而不是直接使用魔数 2048,这样便于维护和修改。
  1. 代码性能:
  • 增加缓冲区大小会稍微增加栈空间使用,但 2048 字节在现代系统中是可以接受的。
  • 性能影响微乎其微,因为这只是增加了缓冲区大小,没有改变算法复杂度。
  1. 代码安全:
  • 这个修改提高了安全性,减少了缓冲区溢出的风险。
  • 2048 字节的大小对于大多数 URL 来说应该是足够的,但仍然建议添加长度检查,以防极端情况。

改进建议:

  1. 定义一个常量来表示缓冲区大小:
const size_t MAX_URI_LENGTH = 2048;
char uri[MAX_URI_LENGTH] = {0};
unsigned long length = FPDFAction_GetURIPath(m_doc, action, uri, MAX_URI_LENGTH);
  1. 添加长度检查:
if (length > 0 && length < MAX_URI_LENGTH) {
    dAnnot->setUrl(uri);
}
  1. 修正变量名拼写:
unsigned long length = FPDFAction_GetURIPath(m_doc, action, uri, MAX_URI_LENGTH);
  1. 考虑使用 std::string 替代 C 风格的字符数组,这样可以更好地处理字符串操作:
std::string uri;
uri.resize(MAX_URI_LENGTH);
unsigned long length = FPDFAction_GetURIPath(m_doc, action, &uri[0], MAX_URI_LENGTH);
if (length > 0 && length < MAX_URI_LENGTH) {
    uri.resize(length);
    dAnnot->setUrl(uri);
}

总体来说,这个修改是合理的,提高了代码的健壮性和安全性,但还可以通过上述建议进一步改进代码质量。

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: LiHua000, max-lvs

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@LiHua000
Copy link
Author

/merge

@deepin-bot deepin-bot bot merged commit a0baf9c into linuxdeepin:develop/eagle Nov 24, 2025
18 checks passed
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.

3 participants