fix: update URL decoding method and refine file ID extraction logic to exclude text-based inputs

This commit is contained in:
CJACK
2026-04-13 03:49:06 +08:00
parent ab9f3cc417
commit 2aee80d0d3
2 changed files with 18 additions and 7 deletions

View File

@@ -292,7 +292,7 @@ func decodeDataURL(raw string, explicitContentType string) ([]byte, string, erro
}
return decoded, contentType, nil
}
decoded, err := url.QueryUnescape(payload)
decoded, err := url.PathUnescape(payload)
if err != nil {
return nil, "", err
}

View File

@@ -8,13 +8,24 @@ func collectOpenAIRefFileIDs(req map[string]any) []string {
}
out := make([]string, 0, 4)
seen := map[string]struct{}{}
for _, raw := range []any{
req["ref_file_ids"],
req["file_ids"],
req["attachments"],
req["messages"],
req["input"],
for _, key := range []string{
"ref_file_ids",
"file_ids",
"attachments",
"messages",
"input",
} {
raw := req[key]
if raw == nil {
continue
}
// Skip top-level strings for 'messages' and 'input' as they are likely plain text content,
// not file IDs. String file IDs are expected in 'ref_file_ids' or 'file_ids'.
if key == "messages" || key == "input" {
if _, ok := raw.(string); ok {
continue
}
}
appendOpenAIRefFileIDs(&out, seen, raw)
}
if len(out) == 0 {