Skip to content

fix: trim trailing newline from apt token to prevent auth failure#174

Merged
dengbo11 merged 1 commit intodeepin-community:masterfrom
myml:fix-patch4
Mar 12, 2026
Merged

fix: trim trailing newline from apt token to prevent auth failure#174
dengbo11 merged 1 commit intodeepin-community:masterfrom
myml:fix-patch4

Conversation

@myml
Copy link
Collaborator

@myml myml commented Mar 12, 2026

The patch was updated to fix authentication failures caused by trailing newline characters in apt tokens. Previously, the getAptToken() function might return tokens containing newline characters, which would cause HTTP header authentication to fail. The new implementation adds trimming of whitespace characters from the token before returning it.

Key changes:

  1. Modified getAptToken() function to trim trailing whitespace characters from the token string
  2. Maintained the same token retrieval logic from apt-config command
  3. Added proper error handling for empty or malformed tokens
  4. The token is now properly formatted before being added to HTTP headers

This ensures that authentication tokens are correctly formatted without extraneous characters that could cause server-side authentication failures.

Log: Fixed authentication issues when pulling packages from repository

Influence:

  1. Test package pull operations with valid apt tokens
  2. Verify authentication succeeds when tokens contain trailing newlines
  3. Test error handling when apt token is missing or empty
  4. Verify HTTP headers are correctly formatted with trimmed tokens
  5. Test repository access with various token formats

fix: 去除 apt token 尾部换行符以防止认证失败

此次补丁更新修复了由于 apt token 中包含尾部换行符导致的认证失败问题。之
前,getAptToken() 函数可能返回包含换行符的 token,这会导致 HTTP 头部认证
失败。新实现添加了对 token 中空白字符的修剪功能。

主要变更:

  1. 修改 getAptToken() 函数以修剪 token 字符串尾部的空白字符
  2. 保持了从 apt-config 命令获取 token 的相同逻辑
  3. 为空或格式错误的 token 添加了适当的错误处理
  4. token 现在在添加到 HTTP 头部之前已正确格式化

这确保了认证令牌在没有可能引起服务器端认证失败的额外字符的情况下被正确格
式化。

Log: 修复从仓库拉取包时的认证问题

Influence:

  1. 使用有效的 apt token 测试包拉取操作
  2. 验证当 token 包含尾部换行符时认证是否成功
  3. 测试 apt token 缺失或为空时的错误处理
  4. 验证使用修剪后的 token 时 HTTP 头部是否正确格式化
  5. 使用各种 token 格式测试仓库访问

The patch was updated to fix authentication failures caused by trailing
newline characters in apt tokens. Previously, the getAptToken() function
might return tokens containing newline characters, which would cause
HTTP header authentication to fail. The new implementation adds trimming
of whitespace characters from the token before returning it.

Key changes:
1. Modified getAptToken() function to trim trailing whitespace
characters from the token string
2. Maintained the same token retrieval logic from apt-config command
3. Added proper error handling for empty or malformed tokens
4. The token is now properly formatted before being added to HTTP
headers

This ensures that authentication tokens are correctly formatted without
extraneous characters that could cause server-side authentication
failures.

Log: Fixed authentication issues when pulling packages from repository

Influence:
1. Test package pull operations with valid apt tokens
2. Verify authentication succeeds when tokens contain trailing newlines
3. Test error handling when apt token is missing or empty
4. Verify HTTP headers are correctly formatted with trimmed tokens
5. Test repository access with various token formats

fix: 去除 apt token 尾部换行符以防止认证失败

此次补丁更新修复了由于 apt token 中包含尾部换行符导致的认证失败问题。之
前,getAptToken() 函数可能返回包含换行符的 token,这会导致 HTTP 头部认证
失败。新实现添加了对 token 中空白字符的修剪功能。

主要变更:
1. 修改 getAptToken() 函数以修剪 token 字符串尾部的空白字符
2. 保持了从 apt-config 命令获取 token 的相同逻辑
3. 为空或格式错误的 token 添加了适当的错误处理
4. token 现在在添加到 HTTP 头部之前已正确格式化

这确保了认证令牌在没有可能引起服务器端认证失败的额外字符的情况下被正确格
式化。

Log: 修复从仓库拉取包时的认证问题

Influence:
1. 使用有效的 apt token 测试包拉取操作
2. 验证当 token 包含尾部换行符时认证是否成功
3. 测试 apt token 缺失或为空时的错误处理
4. 验证使用修剪后的 token 时 HTTP 头部是否正确格式化
5. 使用各种 token 格式测试仓库访问
@dengbo11 dengbo11 merged commit 0979ba9 into deepin-community:master Mar 12, 2026
10 of 11 checks passed
@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: dengbo11
Once this PR has been reviewed and has the lgtm label, please assign liujianqiang-niu for approval. For more information see the Code Review Process.

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

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