Support URL-encoded data-URL favicons - #6191
Open
evnchn wants to merge 4 commits into
Open
Conversation
DateInput applied .props('no-parent-event') to the inner QDate, but
Quasar 2.18.5's QDate has no such prop (noParentEvent belongs to the
anchor-props mixin behind QMenu/QTooltip). It was an inert no-op
attribute; removing it changes no behavior (open/close is driven by the
parent QMenu).
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
`_data_url_to_bytes` assumed every `data:` favicon was base64, so a percent-encoded data URL (the form `_svg_to_data_url` itself generates) was fed to `b64decode`, silently corrupting the bytes or raising `binascii.Error` on `/favicon.ico`. Branch on the `;base64` marker, mirroring `_svg_to_data_url`'s `urllib.parse.quote`, and use `partition` so a comma-less `data:` value no longer raises `ValueError`. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
6 tasks
evnchn
marked this pull request as ready for review
July 25, 2026 06:17
falkoschindler
self-requested a review
July 26, 2026 20:37
The test now sets a URL-encoded data URL via `ui.run` and checks what `/favicon.ico` actually serves, mirroring `test_data_url` right above it. Reverting the fix makes it fail on the user-visible symptom (the route returns 500) rather than on a helper's return value. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Developer passes favicon='data:image/svg+xml,%3Csvg%20.../%3E' (a valid, URL-encoded data URL, the same form NiceGUI generates internally) to ui.run(). is_file() returns False (data: guard), so startup wires get_favicon_response; a request to /favicon.ico calls _data_url_to_bytes -> b64decode drops the '%','<' etc. and returns corrupt bytes served as image/svg+xml. A value like 'data:foo' (no comma) instead raises ValueError -> HTTP 500. Fix: detect the ';base64' marker and branch to urllib.parse.unquote for non-base64 data URLs; guard the missing-comma case.
Minimal reproduction (
nicegui/favicon.py:107):→
BUG REPRODUCED: serving a NiceGUI-generated data-URL favicon raised Error: Incorrect paddingImplementation
Fixed _data_url_to_bytes to branch on ;base64 marker (base64 path byte-identical; percent-encoded uses urllib.parse.unquote) and partition() to drop the comma-less ValueError.
Verification
./nicegui· pylint 10.00/10 · pytest (touched) — all green.Progress