Repository: lipoja/URLExtract

Issue:
should not grab email fragments
```
>>> from urlextract import URLExtract
>>> extractor = URLExtract()
>>> extractor.find_urls("@gmail.com")
['@gmail.com']
>>> extractor.find_urls("bad.email @gmail.com")
['bad.email', '@gmail.com']
```

should not be grabbing `@gmail.com` at all

Discussion:

Patch:
diff --git a/urlextract/urlextract_core.py b/urlextract/urlextract_core.py
index 8f7d5c8..dec043c 100644
--- a/urlextract/urlextract_core.py
+++ b/urlextract/urlextract_core.py
@@ -577,6 +577,10 @@ class URLExtract(CacheFile):
         url_parts = uritools.urisplit(url)
         # <scheme>://<authority>/<path>?<query>#<fragment>
 
+        # authority can't start with @
+        if url_parts.authority.startswith('@'):
+            return False
+
         # if URI contains user info and schema was automatically added
         # the url is probably an email
         if url_parts.getuserinfo() and added_schema:


Test patch:
diff --git a/tests/unit/test_extract_email.py b/tests/unit/test_extract_email.py
index d8c12e6..77352dd 100644
--- a/tests/unit/test_extract_email.py
+++ b/tests/unit/test_extract_email.py
@@ -34,6 +34,7 @@ def test_extract_email_disabled(urlextract, text, expected):
     [
         ("Do not extract emails by default jan@example.com", ["jan@example.com"]),
         ("<email@address.net>", ["email@address.net"]),
+        ("whitespace @address.net>", []),
         ("Given URIs are not mail jan@example.com/asdasd jan@example.com:1234", []),
         ("Given URIs are not mail jan@example.com?not jan@example.com#not", []),
     ],
diff --git a/tests/unit/test_find_urls.py b/tests/unit/test_find_urls.py
index d776bbd..783ca0c 100644
--- a/tests/unit/test_find_urls.py
+++ b/tests/unit/test_find_urls.py
@@ -57,6 +57,7 @@ import pytest
             "<script src='//www.example.com/somejsfile.js'>",
             ["www.example.com/somejsfile.js"],
         ),
+        ("bad.email @address.net>", ['bad.email']),
     ],
 )
 def test_find_urls(urlextract, text, expected):