Repository: pallets/werkzeug

Issue:
New Microsoft Edge User Agent
## Background
Microsoft Edge now based on Chromium and the user agent string is updated.
`Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36 Edg/81.0.416.68`

## Simple Code
```python
@app.route('/browser')
def browser():
    from flask import request
    ua = request.user_agent
    return jsonify({
        'browser': ua.browser,
        'platform': ua.platform,
        'user_agent': ua.string,
        'version': ua.version,
    })
```

## Expected Result
```json
{
  "browser": "edge", 
  "platform": "windows", 
  "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36 Edg/81.0.416.68", 
  "version": "81.0.416.68"
}
```

| Key | Value |
| --- | --- |
| browser | **edge** |
| platform | windows |
| user_agent | Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36 Edg/81.0.416.68 |
| version | **81.0.416.68** |


## Actual Result
```json
{
  "browser": "chrome", 
  "platform": "windows", 
  "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36 Edg/81.0.416.68", 
  "version": "81.0.4044.129"
}
```

| Key | Value |
| --- | --- |
| browser | **chrome** |
| platform | windows |
| user_agent | Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36 Edg/81.0.416.68 |
| version | **81.0.4044.129** |

## Environment
- Windows 10 Pro 1909
- Python 3.6.6
- Werkzeug 0.16.1
- Flask 1.1.1

### Related Issues
#818, #1556


Discussion:

Resolving patch:
diff --git a/src/werkzeug/useragents.py b/src/werkzeug/useragents.py
--- a/src/werkzeug/useragents.py
+++ b/src/werkzeug/useragents.py
@@ -47,7 +47,7 @@ class UserAgentParser(object):
         ("ask jeeves", "ask"),
         (r"aol|america\s+online\s+browser", "aol"),
         (r"opera|opr", "opera"),
-        ("edge", "edge"),
+        ("edge|edg", "edge"),
         ("chrome|crios", "chrome"),
         ("seamonkey", "seamonkey"),
         ("firefox|firebird|phoenix|iceweasel", "firefox"),


Test patch:
diff --git a/tests/test_useragents.py b/tests/test_useragents.py
new file mode 100644
--- /dev/null
+++ b/tests/test_useragents.py
@@ -0,0 +1,44 @@
+# -*- coding: utf-8 -*-
+"""
+    tests.urls
+    ~~~~~~~~~~
+
+    URL helper tests.
+
+    :copyright: 2020 Pallets
+    :license: BSD-3-Clause
+"""
+import pytest
+
+from werkzeug import useragents
+
+
+@pytest.mark.parametrize(
+    ("user_agent", "platform", "browser", "version", "language"),
+    (
+        (
+            "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36 Edge/13.10586",  # noqa B950
+            "windows",
+            "edge",
+            "13.10586",
+            None,
+        ),
+        (
+            "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36 Edg/81.0.416.68",  # noqa B950
+            "windows",
+            "edge",
+            "81.0.416.68",
+            None,
+        ),
+        (
+            "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4123.0 Safari/537.36 Edg/84.0.499.0 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36",  # noqa B950
+            "windows",
+            "edge",
+            "84.0.499.0",
+            None,
+        ),
+    ),
+)
+def test_edge_browsers(user_agent, platform, browser, version, language):
+    parsed = useragents.UserAgentParser()(user_agent)
+    assert parsed == (platform, browser, version, language)