Skip to content

Keep parentheses and plus sign in modelIcon URLs#2942

Closed
krobipd wants to merge 1 commit into
ioBroker:masterfrom
krobipd:fix/2896-modelicon-special-chars
Closed

Keep parentheses and plus sign in modelIcon URLs#2942
krobipd wants to merge 1 commit into
ioBroker:masterfrom
krobipd:fix/2896-modelicon-special-chars

Conversation

@krobipd

@krobipd krobipd commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

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 like YMF40/YDM4109+/YDF40.

sanitizeImageParameter replaced every character outside [a-z\d\-_./:] with a dash, so CK-TLSR8656-SS5-01(7014) became CK-TLSR8656-SS5-01-7014- and the generated URL 404'd:

generated: https://www.zigbee2mqtt.io/images/devices/CK-TLSR8656-SS5-01-7014-.png   -> 404
actual:    https://www.zigbee2mqtt.io/images/devices/CK-TLSR8656-SS5-01(7014).png    -> 200

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:

- const replaceByDash = [/\?/g, /&/g, /[^a-z\d\-_./:]/gi, /[/]/gi];
+ const replaceByDash = [/\?/g, /&/g, /[^a-z\d\-_./:()+]/gi, /[/]/gi];

Verified against the live image server (herdsman-converters 26.73.0):

model resulting filename HTTP
CK-TLSR8656-SS5-01(7014) …SS5-01(7014).png 200
CK-BL702-ROUTER-01(7018) …ROUTER-01(7018).png 200
YMF40/YDM4109+/YDF40 YMF40-YDM4109+-YDF40.png 200
AV2010/14 AV2010-14.png 200
AE 260 AE-260.png 200

This 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

modelIcon is rebuilt on every coordinator connect (doConnectsyncAllDeviceStatesupdateDev writes native.modelIcon for every known device), so devices that already stored the bad URL are corrected on the next adapter restart — no re-pairing needed.

Test plan

  • Functional test over the public getDeviceIcon for the five models above plus a ?/& case (unchanged → dash) — red before the change, green after
  • npm run test:package (56 passing) and npm run test:unit pass
  • npm run lint clean, node --check lib/utils.js ok

Addresses #2896

🤖 Generated with Claude Code

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>
@asgothian

Copy link
Copy Markdown
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.

@asgothian asgothian closed this Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants