homebridge / HAP-NodeJS

Node.js implementation of the HomeKit Accessory Protocol (HAP)
Apache License 2.0
2.69k stars 630 forks source link

fix: ensure we check names using the full UTF-8 character set. #1052

Closed hjdhjd closed 4 months ago

hjdhjd commented 4 months ago

:recycle: Current situation

This further refines #1009 to:

  1. Check names using the UTF-8 character set rather than ASCII.
  2. Ensure we fully comply with HomeKit naming requirements.
  3. Ignores the value if it’s empty. ConfiguredName is an optional characteristic and it’s okay if it’s empty, for instance.
  4. Updates tsconfig to support Node 18 at a minimum (required to get UTF-8 regular expressions).

:bulb: Proposed solution

Refactored and implemented.

:gear: Release Notes

improvement: refinements to HomeKit name validation.

:heavy_plus_sign: Additional Information

If applicable, provide additional context in this section.

Testing

Which tests were added? Which existing tests were adapted/changed? Which situations are covered, and what edge cases are missing?

Reviewer Nudging

@NorthernMan54

donavanbecker commented 4 months ago

CheckName is used for both Name and ConfiguredName, so I feel like what is done in #1049 would be better not?

src/lib/Characteristic.ts