diff --git a/.gitignore b/.gitignore
index f5adb54..26bbdf8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,3 +10,4 @@ build
 docs/_build/
 .cache/
 .eggs/
+.*env*/
diff --git a/bleach/linkifier.py b/bleach/linkifier.py
index 471ce93..c8d3340 100644
--- a/bleach/linkifier.py
+++ b/bleach/linkifier.py
@@ -349,7 +349,17 @@ class LinkifyFilter(Filter):
 
     def handle_links(self, src_iter):
         """Handle links in character tokens"""
+        in_a = False  # happens, if parse_email=True and if a mail was found
         for token in src_iter:
+            if in_a:
+                if token['type'] == 'EndTag' and token['name'] == 'a':
+                    in_a = False
+                yield token
+                continue
+            elif token['type'] == 'StartTag' and token['name'] == 'a':
+                in_a = True
+                yield token
+                continue
             if token['type'] == 'Characters':
                 text = token['data']
                 new_tokens = []
diff --git a/setup.py b/setup.py
old mode 100644
new mode 100755
index 1df9765..7e5c6ca
--- a/setup.py
+++ b/setup.py
@@ -1,3 +1,5 @@
+#!/usr/bin/env python
+
 import re
 import sys
 

Linkify creates http link in mailto link when host contains a hyphen
Linkify creates http links **in** mailto links if the mail host name contains a hyphen `-` (and `parse_email=True`). The http link starts with the hyphen, even if host names mustn't start with hyphens at all (https://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_hostnames).

```py
>>> linkify('foo@exa-mple.com', parse_email=True)
'<a href="mailto:foo@exa-mple.com">foo@exa<a href="http://-mple.com" rel="nofollow">-mple.com</a></a>'
```
This is what the link looks like: <a href="mailto:foo@exa-mple.com">foo@exa<a href="http://-mple.com" rel="nofollow">-mple.com</a></a> :smile:
diff --git a/tests/test_links.py b/tests/test_links.py
index b967151..3d44665 100644
--- a/tests/test_links.py
+++ b/tests/test_links.py
@@ -588,6 +588,14 @@ def test_hang():
     )
 
 
+def test_hyphen_in_mail():
+    """Test hyphens `-` in mails. Issue #300."""
+    assert (
+        linkify('ex@am-ple.com', parse_email=True) ==
+        '<a href="mailto:ex@am-ple.com">ex@am-ple.com</a>'
+    )
+
+
 def test_url_re_arg():
     """Verifies that a specified url_re is used"""
     fred_re = re.compile(r"""(fred\.com)""")

pip install -e .
parse_log_pytest_v2
requirements.txt
apt-get update apt-get install -y gcc
3.6
requirements.txt
pytest -v
alabaster==0.7.13
args==0.1.0
Babel==2.11.0
-e git+https://github.com/mozilla/bleach.git@d77c4b7bf1a967f462d47beb8caa5e803133dfe4#egg=bleach
certifi==2021.5.30
charset-normalizer==2.0.12
clint==0.5.1
distlib==0.3.9
docutils==0.18.1
filelock==3.4.1
flake8==3.3.0
html5lib==1.1
idna==3.10
imagesize==1.4.1
importlib-metadata==4.8.3
importlib-resources==5.4.0
Jinja2==3.0.3
MarkupSafe==2.0.1
mccabe==0.6.1
pkginfo==1.10.0
platformdirs==2.4.0
pluggy==0.4.0
py==1.11.0
pycodestyle==2.3.1
pyflakes==1.5.0
Pygments==2.14.0
pytest==3.0.6
pytest-wholenodeid==0.2
pytz==2025.2
requests==2.27.1
requests-toolbelt==1.0.0
six==1.17.0
snowballstemmer==2.2.0
Sphinx==1.5.2
tox==2.4.1
twine==1.8.1
typing_extensions==4.1.1
urllib3==1.26.20
virtualenv==20.17.1
webencodings==0.5.1
zipp==3.6.0

name: bleach
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - alabaster==0.7.13
      - args==0.1.0
      - babel==2.11.0
      - charset-normalizer==2.0.12
      - clint==0.5.1
      - distlib==0.3.9
      - docutils==0.18.1
      - filelock==3.4.1
      - flake8==3.3.0
      - html5lib==1.1
      - idna==3.10
      - imagesize==1.4.1
      - importlib-metadata==4.8.3
      - importlib-resources==5.4.0
      - jinja2==3.0.3
      - markupsafe==2.0.1
      - mccabe==0.6.1
      - pkginfo==1.10.0
      - platformdirs==2.4.0
      - pluggy==0.4.0
      - py==1.11.0
      - pycodestyle==2.3.1
      - pyflakes==1.5.0
      - pygments==2.14.0
      - pytest==3.0.6
      - pytest-wholenodeid==0.2
      - pytz==2025.2
      - requests==2.27.1
      - requests-toolbelt==1.0.0
      - six==1.17.0
      - snowballstemmer==2.2.0
      - sphinx==1.5.2
      - tox==2.4.1
      - twine==1.8.1
      - typing-extensions==4.1.1
      - urllib3==1.26.20
      - virtualenv==20.17.1
      - webencodings==0.5.1
      - zipp==3.6.0
prefix: /opt/conda/envs/bleach

tests/test_links.py::test_hyphen_in_mail
tests/test_links.py::test_empty tests/test_links.py::test_simple_link tests/test_links.py::test_trailing_slash tests/test_links.py::test_mangle_link tests/test_links.py::test_mangle_text tests/test_links.py::test_email_link["\\\n"@opa.ru-True-"\\\n"@opa.ru] tests/test_links.py::test_set_attrs tests/test_links.py::test_only_proto_links tests/test_links.py::test_stop_email tests/test_links.py::test_tlds[example.yyy-example.yyy] tests/test_links.py::test_tlds[brie-brie] tests/test_links.py::test_escaping tests/test_links.py::test_nofollow_off tests/test_links.py::test_link_in_html tests/test_links.py::test_links_https tests/test_links.py::test_add_rel_nofollow tests/test_links.py::test_url_with_path tests/test_links.py::test_link_ftp tests/test_links.py::test_link_query tests/test_links.py::test_link_fragment tests/test_links.py::test_link_entities tests/test_links.py::test_escaped_html tests/test_links.py::test_link_http_complete tests/test_links.py::test_non_url tests/test_links.py::test_javascript_url tests/test_links.py::test_unsafe_url tests/test_links.py::test_skip_tags tests/test_links.py::test_libgl tests/test_links.py::test_end_of_sentence[example.com-.] tests/test_links.py::test_end_of_sentence[example.com-...] tests/test_links.py::test_end_of_sentence[ex.com/foo-.] tests/test_links.py::test_end_of_sentence[ex.com/foo-....] tests/test_links.py::test_end_of_clause tests/test_links.py::test_wrapping_parentheses[(example.com)-expected_data0] tests/test_links.py::test_wrapping_parentheses[(example.com/)-expected_data1] tests/test_links.py::test_wrapping_parentheses[(example.com/foo)-expected_data2] tests/test_links.py::test_wrapping_parentheses[(((example.com/))))-expected_data3] tests/test_links.py::test_wrapping_parentheses[example.com/))-expected_data4] tests/test_links.py::test_wrapping_parentheses[http://en.wikipedia.org/wiki/Test_(assessment)-expected_data7] tests/test_links.py::test_wrapping_parentheses[(http://en.wikipedia.org/wiki/Test_(assessment))-expected_data8] tests/test_links.py::test_wrapping_parentheses[((http://en.wikipedia.org/wiki/Test_(assessment))-expected_data9] tests/test_links.py::test_wrapping_parentheses[(http://en.wikipedia.org/wiki/Test_(assessment)))-expected_data10] tests/test_links.py::test_wrapping_parentheses[(http://en.wikipedia.org/wiki/)Test_(assessment-expected_data11] tests/test_links.py::test_parentheses_with_removing tests/test_links.py::test_ports[http://foo.com:8000-expected_data0] tests/test_links.py::test_ports[http://foo.com:8000/-expected_data1] tests/test_links.py::test_ports[http://bar.com:xkcd-expected_data2] tests/test_links.py::test_ports[http://foo.com:81/bar-expected_data3] tests/test_links.py::test_ports[http://foo.com:-expected_data4] tests/test_links.py::test_ports[http://foo.com:\u0663\u0669/-expected_data5] tests/test_links.py::test_ports[http://foo.com:\U0001d7e0\U0001d7d8/-expected_data6] tests/test_links.py::test_ignore_bad_protocols tests/test_links.py::test_link_emails_and_urls tests/test_links.py::test_links_case_insensitive tests/test_links.py::test_elements_inside_links tests/test_links.py::test_drop_link_tags tests/test_links.py::test_naughty_unescaping[&lt;br&gt;-&lt;br&gt;] tests/test_links.py::test_hang tests/test_links.py::test_url_re_arg tests/test_links.py::test_email_re_arg tests/test_links.py::test_linkify_idempotent tests/test_links.py::TestLinkify::test_no_href_links tests/test_links.py::TestLinkify::test_rel_already_there tests/test_links.py::TestLinkify::test_only_text_is_linkified
bleach/linkifier.py .gitignore setup.py
bleach/linkifier.py .gitignore setup.py