fix: accept 'ref' as fallback for 'doc' query parameter

Keep backward compatibility for external integrations that still use
the old ?ref= parameter while recommending ?doc= to avoid privacy
extensions blocking.
This commit is contained in:
Benjamin
2026-02-05 23:35:09 +01:00
parent d3e7c9911c
commit 8ef5bb38cb
5 changed files with 19 additions and 5 deletions

View File

@@ -492,8 +492,11 @@ type FindOrCreateDocumentResponse struct {
func (h *Handler) HandleFindOrCreateDocument(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
// Get reference from query parameter (renamed from "ref" to "doc" to avoid ClearURLs blocking)
// "doc" is the primary parameter; "ref" is accepted as fallback for backward compatibility
ref := r.URL.Query().Get("doc")
if ref == "" {
ref = r.URL.Query().Get("ref")
}
if ref == "" {
logger.Logger.Warn("Find or create request missing doc parameter",
"remote_addr", r.RemoteAddr)

View File

@@ -85,8 +85,11 @@ func (h *Handler) HandleProxy(w http.ResponseWriter, r *http.Request) {
startTime := time.Now()
requestID := getRequestID(r.Context())
// Extract parameters
// "doc" is the primary parameter; "ref" is accepted as fallback for backward compatibility
docID := r.URL.Query().Get("doc")
if docID == "" {
docID = r.URL.Query().Get("ref")
}
rawURL := r.URL.Query().Get("url")
// Validate required parameters

View File

@@ -44,8 +44,11 @@ func HandleOEmbed(baseURL string) http.HandlerFunc {
return
}
// Extract doc ID from query parameters
// "doc" is the primary parameter; "ref" is accepted as fallback for backward compatibility
docID := parsedURL.Query().Get("doc")
if docID == "" {
docID = parsedURL.Query().Get("ref")
}
if docID == "" {
logger.Logger.Warn("oEmbed request missing doc parameter in url",
"url", urlParam,

View File

@@ -50,10 +50,12 @@ func EmbedDocumentMiddleware(
return
}
// Get doc ID from query parameter
// "doc" is the primary parameter; "ref" is accepted as fallback for backward compatibility
docID := r.URL.Query().Get("doc")
if docID == "" {
// No doc parameter, let SPA handle it
docID = r.URL.Query().Get("ref")
}
if docID == "" {
next.ServeHTTP(w, r)
return
}

View File

@@ -97,6 +97,9 @@ func serveIndexTemplate(w http.ResponseWriter, r *http.Request, file fs.File, ba
func generateMetaTags(r *http.Request, baseURL string, signatureRepo SignatureRepository) string {
docID := r.URL.Query().Get("doc")
if docID == "" {
docID = r.URL.Query().Get("ref")
}
if docID == "" {
return ""
}