GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Query Tool saves files that were loaded as latin-1 back as UTF-8 · Issue #10531 · pgadmin-org/pgadmin4

Query Tool saves files that were loaded as latin-1 back as UTF-8 #10531

New issue
Copy link
New issue
Copy link
Closed
Closed
Query Tool saves files that were loaded as latin-1 back as UTF-8#10531
Copy link
Labels
Bug

Description

@dpage
dpage
opened on Oct 12, 2026
Issue body actions

When a file without a BOM contains bytes that are not valid UTF-8 (for example a Latin-1 é, byte 0xE9), the Query Tool loads it correctly by falling back to latin-1, but saving it back writes the content as UTF-8, so every non-ASCII character silently changes on disk (0xE9 becomes 0xC3 0xA9).

Cause: check_file_for_bom_and_binary() records the encoding in Filemanager.loaded_file_encoding_list based only on the first 1024 bytes, so a file without a BOM is stored as utf-8 (web/pgadmin/misc/file_manager/__init__.py:1251). The latin-1 fallback happens later, inside read_file_generator() (:130), and is never recorded. save_file() then looks up the stored utf-8 and encodes with it (:477).

To reproduce:

  1. printf 'SELECT 1; -- caf\xe9\n' > latin1.sql
  2. Open latin1.sql in the Query Tool; it displays café correctly.
  3. Save without changes.
  4. xxd latin1.sql shows c3 a9 where e9 was.

Expected: a file that was decoded as latin-1 is saved as latin-1, so an unedited round trip leaves it byte-for-byte unchanged.

A likely fix is for read_file_generator() to update the stored encoding when it falls back. Note that the list is keyed only on the file's basename and shared across users, which may be worth tidying at the same time.

Found whilst reviewing #10508.

Activity

  1. dpage
    added
    Bug
    on Oct 12, 2026
  2. dpage
    added a commit that references this issue on Oct 13, 2026

    Fix the Query Tool saving files that were loaded as latin-1 back as U…

    ccdb1f6
  3. dpage commented on Oct 13, 2026

    @dpage
    dpage
    on Oct 13, 2026
    ContributorAuthor
    More actions

    Fixed by #10537 (ccdb1f6).

  4. dpage
    closed this as completedon Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.