internal/frontend: exclude paths case-sensitively
Provide a way to exclude paths exactly (case-sensitively).
The usual exclusion mechanism is case-insensitive, which is a problem
for those who want to exclude only particular casings of their module.
For example, IBM would like their name in all caps, but some older
packages were published under "ibm".
Exclude "github.com/ibm/sarama".
For golang/go#71342.
Change-Id: I848e261458013e364f850daf6474ba6fd7136f25
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/645636
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
kokoro-CI: kokoro <noreply+kokoro@google.com>
diff --git a/internal/frontend/details.go b/internal/frontend/details.go
index 0323f04..19e2b94 100644
--- a/internal/frontend/details.go
+++ b/internal/frontend/details.go
@@ -87,6 +87,9 @@
}
func checkExcluded(ctx context.Context, ds internal.DataSource, fullPath, version string) error {
+ if caseSensitiveExcludedPaths[fullPath] {
+ return &serrors.ServerError{Status: http.StatusNotFound}
+ }
db, ok := ds.(internal.PostgresDB)
if !ok {
return nil
@@ -97,3 +100,9 @@
}
return nil
}
+
+// Paths to exclude if they match exactly.
+// These are very rare, so it's simpler to hardcode them rather than use the DB.
+var caseSensitiveExcludedPaths = map[string]bool{
+ "github.com/ibm/sarama": true, // https://go.dev/issue/71342
+}