Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Special Characters in Name #1008

Closed
NorthernMan54 opened this issue Jun 27, 2023 · 11 comments · Fixed by #1009
Closed

Special Characters in Name #1008

NorthernMan54 opened this issue Jun 27, 2023 · 11 comments · Fixed by #1009

Comments

@NorthernMan54
Copy link
Contributor

Analysis

@Supereg With the recent IOS versions I have noticed that accessory names are now being checked for special characters or emoji, and am thinking that we should add an error or warning message when these are being used. I was using ( and ), but there are likely others. I did find that - did not trigger the message

IMG_1381
IMG_1380

Am wondering if this is a potential trigger of this issue - homebridge/homebridge#3373 (comment)

Expected Behavior

An error or warning message to be logged when a accessory name contains an unsupported character.

Steps To Reproduce

Create an accessory with invalid character

Logs

None

Configuration

not needed

Environment

  • OS:
  • Software:
  • Node:
  • npm:

Process Supervisor

hb-service

Additional Context

No response

@n0rt0nthec4t
Copy link

This has always been the case and have code to validate names on my stuff

https://developer.apple.com/design/human-interface-guidelines/homekit

Use only alphanumeric, space, and apostrophe characters.
Start and end with an alphabetic or numeric character.
Don’t include emojis.

I have a function like this

    function validateHomeKitName(nameToMakeValid) {
        // Strip invalid characters to meet HomeKit naming requirements
        // Ensure only letters or numbers are at the beginning AND/OR end of string
        return nameToMakeValid.replace(/[^A-Za-z0-9 ,.-]/g, "").replace(/^[^a-zA-Z0-9]*/g, "").replace(/[^a-zA-Z0-9]+$/g, "");
    }

@ebaauw
Copy link
Contributor

ebaauw commented Jun 27, 2023

HomeKit also chokes on a Manufacturer Name with a /.

@Supereg
Copy link
Member

Supereg commented Jun 27, 2023

We might extend the sanity checks we already have in Accessory.validateAccessory. There we check for empty values for those Characteristics.

I'm not sure if it makes sense to automatically alter names(?). We could offer some help if they attempt it in Homebridge UI, but we can't really prevent it, if they configure accessory names via the config themselves.

@NorthernMan54
Copy link
Contributor Author

NorthernMan54 commented Jun 27, 2023

@Supereg Am thinking your recommendation to extend Accessory.validateAccessory with the check creating a log entry makes the most sense. Something similar to the existing checks.

Give me a few days, and I will submit a pull request.

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label Jul 28, 2023
@NorthernMan54
Copy link
Contributor Author

Not stale

@muenzpraeger
Copy link

I wonder if the current implementation is too restrictive, as dash or punctuation are a) not uncommon and b) supported by HomeKit.

Rolling out this change as is may result in a lot of confusion (and many people goint to rework their setup, even if it is not needed).

@NorthernMan54
Copy link
Contributor Author

@muenzpraeger see above #1008 (comment)

@muenzpraeger
Copy link

I'm aware of the HIG reference. Now, I've at least 40 different accessories that have a special character (. or -) in their name, and now I'm being spammed on startup.

I'd say it's ok for doing a validation check when a new accessory is created. Not for existing devices. Alternatively the option should be available to disable this warning.

@NorthernMan54
Copy link
Contributor Author

@muenzpraeger What happens when you edit the name in the Home app ? I found that I couldn't save the edited name, hence us adding the warning.

@muenzpraeger
Copy link

Works for me (at least with . and -. Video is low-res b/c of GitHub file limits.

special_characters.mov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants