Skip to content

[Sources] Improve regex to match GitHub-generated archives #409

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

Merged
merged 1 commit into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Sources.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function check_github_archive(url::String)
# <https://github.com/bazel-contrib/SIG-rules-authors/issues/11#issuecomment-1029861300>
# the `/archive/refs/tags` should be more stable, but that didn't happen in the incident
# on 2023-01-30, so it's unclear whether we can trust them.
if contains(url, r"github.com/[^/]+/[^/]+/archive/(refs/tags/)?[^/]+\.(tar\.gz|zip)$")
if contains(url, r"github.com/[^/]+/[^/]+/archive/(refs/tags/(releases/)?)?[^/]+\.(tar\.gz|zip)$")
throw(ArgumentError("""
The archive automatically generated by GitHub
$(url)
Expand Down
1 change: 1 addition & 0 deletions test/sources.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ using JSON
@test_throws ArgumentError ArchiveSource("https://github.com/ralna/ARCHDefs/archive/refs/tags/v2.0.3x.tar.gz", "6583e27f84338447767bbdf4335514c8836ae4ad54f5e66280307e8b57189cff")
@test_throws ArgumentError FileSource("https://github.com/ralna/ARCHDefs/archive/v2.0.3x.tar.gz", "6583e27f84338447767bbdf4335514c8836ae4ad54f5e66280307e8b57189cff")
@test_throws ArgumentError FileSource("https://github.com/ralna/ARCHDefs/archive/refs/tags/v2.0.3x.tar.gz", "6583e27f84338447767bbdf4335514c8836ae4ad54f5e66280307e8b57189cff")
@test_throws ArgumentError FileSource("https://github.com/coin-or/qpOASES/archive/refs/tags/releases/3.2.1.zip", "28dbe55fdfdca5f8a43e8fbfbdb5a90c52546568f8ecc7b29bd1d42dc1ccdd2a")

@test SetupSource("https://ftp.gnu.org/gnu/wget/wget-1.20.3.tar.gz", "wget-1.20.3.tar.gz", "", "") isa SetupSource{ArchiveSource}
@test SetupSource("https://ftp.gnu.org/gnu/wget/wget-1.20.3.zip", "wget-1.20.3.zip", "", "") isa SetupSource{ArchiveSource}
Expand Down
Loading