Skip to content

Commit

Permalink
Merge pull request #127 from markmcclain/validchars
Browse files Browse the repository at this point in the history
Ensure dbus object path is only valid chars
  • Loading branch information
kevincar authored Mar 6, 2024
2 parents 7572b6a + 5841313 commit 059de19
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion bless/backends/bluezdbus/dbus/application.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import re

import bleak.backends.bluezdbus.defs as defs # type: ignore

from typing import List, Any, Callable, Optional, Union
Expand Down Expand Up @@ -45,7 +47,12 @@ def __init__(
self.destination: str = destination
self.bus: MessageBus = bus

self.base_path: str = "/org/bluez/" + self.app_name.replace(" ", "")
# Valid path must be ASCII characters "[A-Z][a-z][0-9]_"
# see https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-marshaling-object-path

self.base_path: str = (
"/org/bluez/" + re.sub( '[^A-Za-z0-9_]', '', self.app_name )
)
self.advertisements: List[BlueZLEAdvertisement] = []
self.services: List[BlueZGattService] = []

Expand Down

0 comments on commit 059de19

Please sign in to comment.