[PR #21456] fix: use RFC 5987 encoding for non-ASCII knowledge export filenames #49136

Open
opened 2026-04-30 01:27:14 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/21456
Author: @sangyongsin
Created: 2/16/2026
Status: 🔄 Open

Base: devHead: fix/knowledge-export-non-ascii-filename


📝 Commits (1)

  • 6d554e5 fix: use RFC 5987 encoding for non-ASCII knowledge export filenames

📊 Changes

1 file changed (+6 additions, -1 deletions)

View changed files

📝 backend/open_webui/routers/knowledge.py (+6 -1)

📄 Description

Pull Request Checklist

  • Target branch: Verify that the pull request targets the dev branch.
  • Description: Provided below.
  • Changelog: Provided below.
  • Documentation: No user-facing behavior changes requiring docs update.
  • Dependencies: No new dependencies. urllib.parse.quote is Python standard library.
  • Testing: Manually tested with Korean, Chinese, and ASCII knowledge base names.
  • Agentic AI Code: This PR has been manually reviewed and tested by a human.
  • Code review: Self-reviewed.
  • Design & Architecture: Minimal change, no new settings.
  • Git Hygiene: Single atomic commit.
  • Title Prefix: fix:

Changelog Entry

Description

When exporting a knowledge base as ZIP, non-ASCII characters (Korean, Chinese, Japanese, etc.) in the filename are corrupted because the Content-Disposition header puts them directly in the filename
parameter, which only supports ASCII (latin-1 encoding).

This fix adds RFC 5987 filename*=UTF-8'' with percent-encoded filename, which is supported by all modern browsers (IE11+, Chrome, Firefox, Edge, Safari).

Added

  • urllib.parse.quote import for percent-encoding

Changed

  • N/A

Deprecated

  • N/A

Removed

  • N/A

Fixed

  • Knowledge base ZIP export now correctly handles non-ASCII filenames using RFC 5987 filename*=UTF-8'' encoding
  • ASCII-safe generic fallback (knowledge.zip) for filename parameter to prevent header encoding errors

Security

  • N/A

Breaking Changes

  • N/A

Additional Information

  • The filename parameter uses a generic ASCII fallback since filename* is supported by all modern browsers, and the added complexity of ASCII detection provides no practical benefit.
  • Only 2 lines of code added, no existing logic modified.

Before (corrupted):
Content-Disposition: attachment; filename=회사규정.zip
→ Non-ASCII in filename causes latin-1 encoding failure → corrupted filename

After (fixed):
Content-Disposition: attachment; filename="knowledge.zip"; filename*=UTF-8''%ED%9A%8C%EC%82%AC%EA%B7%9C%EC%A0%95.zip
→ Modern browsers use filename* → correct Korean filename displayed

Screenshots or Videos

  • N/A (backend-only change, no UI modification)

Contributor License Agreement

By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and
I am providing my contributions under its terms.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/21456 **Author:** [@sangyongsin](https://github.com/sangyongsin) **Created:** 2/16/2026 **Status:** 🔄 Open **Base:** `dev` ← **Head:** `fix/knowledge-export-non-ascii-filename` --- ### 📝 Commits (1) - [`6d554e5`](https://github.com/open-webui/open-webui/commit/6d554e596c528e58cfffc32f879fd678cb8f2212) fix: use RFC 5987 encoding for non-ASCII knowledge export filenames ### 📊 Changes **1 file changed** (+6 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/routers/knowledge.py` (+6 -1) </details> ### 📄 Description # Pull Request Checklist - [x] **Target branch:** Verify that the pull request targets the `dev` branch. - [x] **Description:** Provided below. - [x] **Changelog:** Provided below. - [ ] **Documentation:** No user-facing behavior changes requiring docs update. - [ ] **Dependencies:** No new dependencies. `urllib.parse.quote` is Python standard library. - [x] **Testing:** Manually tested with Korean, Chinese, and ASCII knowledge base names. - [x] **Agentic AI Code:** This PR has been manually reviewed and tested by a human. - [x] **Code review:** Self-reviewed. - [x] **Design & Architecture:** Minimal change, no new settings. - [x] **Git Hygiene:** Single atomic commit. - [x] **Title Prefix:** `fix:` # Changelog Entry ### Description When exporting a knowledge base as ZIP, non-ASCII characters (Korean, Chinese, Japanese, etc.) in the filename are corrupted because the `Content-Disposition` header puts them directly in the `filename` parameter, which only supports ASCII (latin-1 encoding). This fix adds RFC 5987 `filename*=UTF-8''` with percent-encoded filename, which is supported by all modern browsers (IE11+, Chrome, Firefox, Edge, Safari). ### Added - `urllib.parse.quote` import for percent-encoding ### Changed - N/A ### Deprecated - N/A ### Removed - N/A ### Fixed - Knowledge base ZIP export now correctly handles non-ASCII filenames using RFC 5987 `filename*=UTF-8''` encoding - ASCII-safe generic fallback (`knowledge.zip`) for `filename` parameter to prevent header encoding errors ### Security - N/A ### Breaking Changes - N/A --- ### Additional Information - The `filename` parameter uses a generic ASCII fallback since `filename*` is supported by all modern browsers, and the added complexity of ASCII detection provides no practical benefit. - Only 2 lines of code added, no existing logic modified. **Before (corrupted):** Content-Disposition: attachment; filename=회사규정.zip → Non-ASCII in `filename` causes latin-1 encoding failure → corrupted filename **After (fixed):** Content-Disposition: attachment; filename="knowledge.zip"; filename*=UTF-8''%ED%9A%8C%EC%82%AC%EA%B7%9C%EC%A0%95.zip → Modern browsers use `filename*` → correct Korean filename displayed ### Screenshots or Videos - N/A (backend-only change, no UI modification) ### Contributor License Agreement By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-30 01:27:14 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#49136