Keep parentheses and plus sign in modelIcon URLs#2942
Closed
krobipd wants to merge 1 commit into
Closed
Conversation
sanitizeImageParameter replaced every character outside [a-z\d\-_./:]
with a dash, so a model like "CK-TLSR8656-SS5-01(7014)" became
"CK-TLSR8656-SS5-01-7014-", and the resulting
zigbee2mqtt.io/images/devices URL returned 404 — the device showed the
default "unavailable" icon and the icon download failed.
The z2m image filename is an exact match of the device model
(herdsman-converters keeps "(", ")" and "+" verbatim; only "/" and
spaces are turned into "-"). Verified against the live image server for
herdsman-converters 26.73.0:
CK-TLSR8656-SS5-01(7014).png 200 (parens kept)
CK-BL702-ROUTER-01(7018).png 200 (parens kept)
YMF40-YDM4109+-YDF40.png 200 (slash->dash, plus kept)
AV2010-14.png 200 (slash->dash)
AE-260.png 200 (space->dash)
Adding "()" and "+" to the allowed character class fixes every parens
(31) and plus (39) device without touching the slash (117) or space
(738) devices, whose dash replacement stays correct.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Collaborator
|
This PR falls short of the requirements. An alternative fix is already in place for the (), the + will be added in the near future. |
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.
The problem
Devices whose model name contains parentheses or a plus sign show the default "unavailable" icon, and the icon download fails with HTTP 404. The reported case is
CK-TLSR8656-SS5-01(7014); the same class also hits e.g. Yale locks likeYMF40/YDM4109+/YDF40.sanitizeImageParameterreplaced every character outside[a-z\d\-_./:]with a dash, soCK-TLSR8656-SS5-01(7014)becameCK-TLSR8656-SS5-01-7014-and the generated URL 404'd:The fix
The z2m image filename is an exact match of the device model — herdsman-converters keeps
(,)and+verbatim; only/and spaces are turned into-. Adding()and+to the allowed character class is the whole change:Verified against the live image server (herdsman-converters 26.73.0):
CK-TLSR8656-SS5-01(7014)…SS5-01(7014).pngCK-BL702-ROUTER-01(7018)…ROUTER-01(7018).pngYMF40/YDM4109+/YDF40YMF40-YDM4109+-YDF40.pngAV2010/14AV2010-14.pngAE 260AE-260.pngThis fixes every parens (31) and plus (39) model without changing the slash (117) or space (738) models, whose dash replacement stays correct.
?and&are still replaced.Existing devices
modelIconis rebuilt on every coordinator connect (doConnect→syncAllDeviceStates→updateDevwritesnative.modelIconfor every known device), so devices that already stored the bad URL are corrected on the next adapter restart — no re-pairing needed.Test plan
getDeviceIconfor the five models above plus a?/&case (unchanged → dash) — red before the change, green afternpm run test:package(56 passing) andnpm run test:unitpassnpm run lintclean,node --check lib/utils.jsokAddresses #2896
🤖 Generated with Claude Code