Skip to content

Commit b706cf3

Browse files
mnriemCopilot
andcommitted
fix: URL-encode tag in release API URL to handle special characters
Encode the tag as a path segment (using quote with safe='') when building the releases/tags/<tag> API URL. This prevents malformed URLs when tags contain reserved characters like '/' or '#'. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 7e525fa commit b706cf3

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/specify_cli/_github_http.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import os
1010
import urllib.request
1111
from typing import Callable, Dict, Optional
12-
from urllib.parse import unquote, urlparse
12+
from urllib.parse import quote, unquote, urlparse
1313

1414
# GitHub-owned hostnames that should receive the Authorization header.
1515
# Includes codeload.github.com because GitHub archive URL downloads
@@ -133,7 +133,8 @@ def resolve_github_release_asset_api_url(
133133

134134
owner, repo, tag = parts[0], parts[1], parts[4]
135135
asset_name = "/".join(parts[5:])
136-
release_url = f"https://api.github.com/repos/{owner}/{repo}/releases/tags/{tag}"
136+
encoded_tag = quote(tag, safe="")
137+
release_url = f"https://api.github.com/repos/{owner}/{repo}/releases/tags/{encoded_tag}"
137138

138139
try:
139140
with open_url_fn(release_url, timeout=timeout) as response:

0 commit comments

Comments
 (0)