-
Notifications
You must be signed in to change notification settings - Fork 2
不应使用切片获取 client_id #6
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |||||
| from rich.table import Table | ||||||
| from rich.live import Live | ||||||
| from utils import find_qr_code | ||||||
| import re | ||||||
|
|
||||||
| with open("./config.yaml") as stream: | ||||||
| try: | ||||||
|
|
@@ -49,11 +50,13 @@ | |||||
| logging.info("识别成功,二维码内容:" + qrRaw) | ||||||
| break | ||||||
|
|
||||||
| store = local_data(clientId=qrRaw[81:]) | ||||||
| match = re.search(r":(\d+)/([0-9a-fA-F-]+)", qrRaw) | ||||||
| uuid_str = match.group(2) if match else None | ||||||
|
|
||||||
| store = local_data(clientId=uuid_str) | ||||||
| store.limitA = int(config["Channel_A_limit"]) | ||||||
| store.limitB = int(config["Channel_B_limit"]) | ||||||
|
|
||||||
|
|
||||||
| def on_message(ws, message_raw): | ||||||
| logger.debug(f"Received message: {message_raw}") | ||||||
| message_dict: dict = json.loads(message_raw) | ||||||
|
|
@@ -79,7 +82,7 @@ def on_message(ws, message_raw): | |||||
| break_(ws, message) | ||||||
| elif message.type_ == "error": | ||||||
| error(ws, message) | ||||||
| response(ws, "feedback-0", store) | ||||||
| # response(ws, "feedback-0", store) | ||||||
|
||||||
| # response(ws, "feedback-0", store) | |
| # response(ws, "feedback-0", store) # Temporarily disabled to avoid sending automatic feedback messages; re-enable if feedback responses are required. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The regex extraction can result in uuid_str being None if the pattern doesn't match, but there's no error handling or validation before passing it to local_data(clientId=uuid_str). This could cause issues downstream when the clientId is used in websocket messages. Consider adding validation to ensure the match was successful and handle the case where it fails, such as logging an error and exiting gracefully.