Skip to content
GitLab
项目 群组 主题 代码片段
  • /
  • 帮助
    • 帮助
    • 支持
    • 社区论坛
    • 提交反馈
  • 登录
  • L large
  • 项目信息
    • 项目信息
    • 动态
    • 标记
    • 成员
  • 仓库
    • 仓库
    • 文件
    • 提交
    • 分支
    • 标签
    • 贡献者统计
    • 分支图
    • 比较修订版本
  • 议题 21
    • 议题 21
    • 列表
    • 看板
    • 服务台
    • 里程碑
  • 合并请求 12
    • 合并请求 12
  • CI/CD
    • CI/CD
    • 流水线
    • 作业
    • 产物
    • 计划
  • 部署
    • 部署
    • 环境
    • 发布
  • 软件包与镜像库
    • 软件包与镜像库
    • 软件包库
    • 容器镜像库
    • Terraform 模块
    • 模型实验
  • 监控
    • 监控
    • 事件
  • 分析
    • 分析
    • 价值流
    • CI/CD
    • 仓库
  • Wiki
    • Wiki
  • 代码片段
    • 代码片段
  • 动态
  • 分支图
  • 创建新议题
  • 作业
  • 提交
  • 议题看板
收起侧边栏
  • 王权利
  • large
  • 议题
  • #6954

404 on API URL for namespace including period because gitlab expects nonstandard URLS (RFC 3986)

Created by: stephens2424

For instance, I have the repository: gitlab.example.com/stephen.searles/myrepo, thus the URL to a path's raw blob would be:

https://gitlab.example.com/api/v3/projects/{ID}/repository/raw_blobs/path?private_token={TOKEN}

where {ID} is {NAMESPACE}/{REPO}. The problem here is that my namespace includes a period character and Gitlab is expecting that period to be URL-encoded. Gitlab responds as such in the following cases:

encoding response status
stephen.searles/php 404
stephen.searles%2Fphp 404
stephen%2Esearles%2Fphp 200

Since the period is an unreserved character, Gitlab should be treating those last two cases the same, per RFC 3986 section 2.3:

URIs that differ in the replacement of an unreserved character with its corresponding percent-encoded US-ASCII octet are equivalent: they identify the same resource. However, URI comparison implementations do not always perform normalization prior to comparison (see Section 6). For consistency, percent-encoded octets in the ranges of ALPHA (%41-%5A and %61-%7A), DIGIT (%7.8-%39), hyphen (%2D), period (%2E), underscore (%5F), or tilde (%7E) should not be created by URI producers and, when found in a URI, should be decoded to their corresponding unreserved characters by URI normalizers.

This causes an issue when using HTTP clients that do standard normalization, requiring you to defeat that process to send Gitlab the nonstandard URLs it expects.

I found this while working with this Gitlab library in Go, but determined it's an artifact of the Go HTTP library's URL normalization process.

指派人
分配到
工时统计