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

feat: add Huawei HarmonyOS parser #604

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

KyoUK4n
Copy link

@KyoUK4n KyoUK4n commented Dec 5, 2024

Add Huawei HarmonyOS parser

regexes.yaml Outdated
os_replacement: 'Harmony'
os_v1_replacement: '$1'
os_v2_replacement: '$2'
os_v3_replacement: '$3'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

os_v1 / v2 / v3 replacements are not needed, as it will take the capture groups above in order

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see

regexes.yaml Outdated
@@ -1915,6 +1915,13 @@ os_parsers:
os_v2_replacement: '$2'
os_v3_replacement: '$3'

# Huawei HarmonyOS
- regex: 'HarmonyOS\s?(\d*).?(\d*).?(\d*)'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use \d+, as otherwise this might mess up the capture groups - also, are those actually optional? if not, let's enforce a format such as \d+\.\d+\.\d+

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some Harmony OS User-Agent strings may not explicitly include the version number. Here are two examples:

e.g.

  1. with version
Mozilla/5.0 (Linux; Android 12; LIO-AN00 Build/HUAWEILIO-AN00; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/97.0.4692.98 Mobile Safari/537.36 T7/13.76 BDOS/1.0 (HarmonyOS 3.0.0) SP-engine/3.17.0 baiduboxapp/13.76.0.10 (Baidu; P1 12) NABar/1.0
  1. without version
Mozilla/5.0 (Linux; Android 12; HarmonyOS; CET-AL00; HMSCore 6.14.0.322) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.5735.196 HuaweiBrowser/15.0.9.300 Mobile Safari/537.36

Copy link
Author

@KyoUK4n KyoUK4n Dec 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about this regex: (HarmonyOS)[\s;]+(\d+|)\.?(\d+|)\.?(\d+|)

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