diff --git a/bleach/sanitizer.py b/bleach/sanitizer.py
index c60c26b..79b80f5 100644
--- a/bleach/sanitizer.py
+++ b/bleach/sanitizer.py
@@ -395,7 +395,18 @@ class BleachSanitizerFilter(html5lib_shim.SanitizerFilter):
             if part.startswith('&'):
                 entity = html5lib_shim.match_entity(part)
                 if entity is not None:
-                    new_tokens.append({'type': 'Entity', 'name': entity})
+                    if entity == 'amp':
+                        # LinkifyFilter can't match urls across token boundaries
+                        # which is problematic with &amp; since that shows up in
+                        # querystrings all the time. This special-cases &amp;
+                        # and converts it to a & and sticks it in as a
+                        # Characters token. It'll get merged with surrounding
+                        # tokens in the BleachSanitizerfilter.__iter__ and
+                        # escaped in the serializer.
+                        new_tokens.append({'type': 'Characters', 'data': '&'})
+                    else:
+                        new_tokens.append({'type': 'Entity', 'name': entity})
+
                     # Length of the entity plus 2--one for & at the beginning
                     # and and one for ; at the end
                     remainder = part[len(entity) + 2:]

LinkifyFilter with clean breaks links at &amp;
(Split out to a new issue from [this comment](https://github.com/mozilla/bleach/issues/419#issuecomment-445056894))

When using `LinkifyFilter` instead of the stand-alone `linkify`, links are broken at any `&amp;`, but not bare `&` characters.

Here's a pretty minimal demonstration:

```
import bleach

bleach.linkify("https://www.youtube.com/watch?v=SkcucKDrbOI&amp;feature=youtu.be")
```

Result (expected): `<a href="https://www.youtube.com/watch?v=SkcucKDrbOI&amp;feature=youtu.be" rel="nofollow">https://www.youtube.com/watch?v=SkcucKDrbOI&amp;feature=youtu.be</a>`

```
import bleach
from functools import partial

bleach_linkifier = partial(bleach.linkifier.LinkifyFilter)
cleaner = bleach.Cleaner(filters=[bleach_linkifier])
cleaner.clean("https://www.youtube.com/watch?v=SkcucKDrbOI&amp;feature=youtu.be")
```

Result (not expected, link stops at the `&amp;`): `<a href="https://www.youtube.com/watch?v=SkcucKDrbOI">https://www.youtube.com/watch?v=SkcucKDrbOI</a>&amp;feature=<a href="http://youtu.be">youtu.be</a>`

It works with just a bare `&` instead of the `&amp;`, like `https://www.youtube.com/watch?v=SkcucKDrbOI&feature=youtu.be`. In that case, the output of both methods is:

```
<a href="https://www.youtube.com/watch?v=SkcucKDrbOI&amp;feature=youtu.be">https://www.youtube.com/watch?v=SkcucKDrbOI&amp;feature=youtu.be</a>
```

(with an additional `rel="nofollow"` attr added by `linkify()` by default)
diff --git a/tests/test_linkify.py b/tests/test_linkify.py
index 584a5b0..ab1c513 100644
--- a/tests/test_linkify.py
+++ b/tests/test_linkify.py
@@ -694,6 +694,10 @@ class TestLinkify:
         'http://example.com?b=1&c=2',
         '<a href="http://example.com?b=1&amp;c=2">http://example.com?b=1&amp;c=2</a>'
     ),
+    (
+        'http://example.com?b=1&amp;c=2',
+        '<a href="http://example.com?b=1&amp;c=2">http://example.com?b=1&amp;c=2</a>'
+    ),
     (
         'link: https://example.com/watch#anchor',
         'link: <a href="https://example.com/watch#anchor">https://example.com/watch#anchor</a>'

pip install -e .
parse_log_pytest
requirements.txt
pytest pytest-wholenodeid
3.6
requirements-dev.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
alabaster==0.7.13
attrs==22.2.0
Babel==2.11.0
-e git+https://github.com/mozilla/bleach.git@3097fd3466118539a30d2e3a2a469113aa007cbe#egg=bleach
certifi==2021.5.30
cffi==1.15.1
charset-normalizer==2.0.12
colorama==0.4.5
cryptography==40.0.2
distlib==0.3.9
docutils==0.17.1
filelock==3.4.1
flake8==5.0.4
idna==3.10
imagesize==1.4.1
importlib-metadata==4.2.0
importlib-resources==5.4.0
iniconfig==1.1.1
jeepney==0.7.1
Jinja2==3.0.3
keyring==23.4.1
MarkupSafe==2.0.1
mccabe==0.7.0
packaging==21.3
pkginfo==1.10.0
platformdirs==2.4.0
pluggy==1.0.0
py==1.11.0
pycodestyle==2.9.1
pycparser==2.21
pyflakes==2.5.0
Pygments==2.14.0
pyparsing==3.1.4
pytest==7.0.1
pytest-wholenodeid==0.2
pytz==2025.2
readme-renderer==34.0
requests==2.27.1
requests-toolbelt==1.0.0
rfc3986==1.5.0
SecretStorage==3.3.3
six==1.17.0
snowballstemmer==2.2.0
Sphinx==4.3.2
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
toml==0.10.2
tomli==1.2.3
tox==3.28.0
tqdm==4.64.1
twine==3.8.0
typing_extensions==4.1.1
urllib3==1.26.20
virtualenv==20.16.2
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
      - attrs==22.2.0
      - babel==2.11.0
      - cffi==1.15.1
      - charset-normalizer==2.0.12
      - colorama==0.4.5
      - cryptography==40.0.2
      - distlib==0.3.9
      - docutils==0.17.1
      - filelock==3.4.1
      - flake8==5.0.4
      - idna==3.10
      - imagesize==1.4.1
      - importlib-metadata==4.2.0
      - importlib-resources==5.4.0
      - iniconfig==1.1.1
      - jeepney==0.7.1
      - jinja2==3.0.3
      - keyring==23.4.1
      - markupsafe==2.0.1
      - mccabe==0.7.0
      - packaging==21.3
      - pkginfo==1.10.0
      - platformdirs==2.4.0
      - pluggy==1.0.0
      - py==1.11.0
      - pycodestyle==2.9.1
      - pycparser==2.21
      - pyflakes==2.5.0
      - pygments==2.14.0
      - pyparsing==3.1.4
      - pytest==7.0.1
      - pytest-wholenodeid==0.2
      - pytz==2025.2
      - readme-renderer==34.0
      - requests==2.27.1
      - requests-toolbelt==1.0.0
      - rfc3986==1.5.0
      - secretstorage==3.3.3
      - six==1.17.0
      - snowballstemmer==2.2.0
      - sphinx==4.3.2
      - sphinxcontrib-applehelp==1.0.2
      - sphinxcontrib-devhelp==1.0.2
      - sphinxcontrib-htmlhelp==2.0.0
      - sphinxcontrib-jsmath==1.0.1
      - sphinxcontrib-qthelp==1.0.3
      - sphinxcontrib-serializinghtml==1.1.5
      - toml==0.10.2
      - tomli==1.2.3
      - tox==3.28.0
      - tqdm==4.64.1
      - twine==3.8.0
      - typing-extensions==4.1.1
      - urllib3==1.26.20
      - virtualenv==20.16.2
      - webencodings==0.5.1
      - zipp==3.6.0
prefix: /opt/conda/envs/bleach

tests/test_linkify.py::test_linkify_filter[http://example.com?b=1&amp;c=2-<a
tests/test_linkify.py::test_empty tests/test_linkify.py::test_simple_link tests/test_linkify.py::test_trailing_slash tests/test_linkify.py::test_mangle_link tests/test_linkify.py::test_mangle_text tests/test_linkify.py::test_invalid_attribute_names tests/test_linkify.py::test_email_link[a tests/test_linkify.py::test_email_link[aussie tests/test_linkify.py::test_email_link[email tests/test_linkify.py::test_email_link[<br>jinkyun@example.com-True-<br><a tests/test_linkify.py::test_email_link[mailto tests/test_linkify.py::test_email_link["\\\n"@opa.ru-True-"\\\n"@opa.ru] tests/test_linkify.py::test_email_link_escaping["james"@example.com-<a tests/test_linkify.py::test_email_link_escaping["j'ames"@example.com-<a tests/test_linkify.py::test_email_link_escaping["ja>mes"@example.com-<a tests/test_linkify.py::test_prevent_links[callback0-a tests/test_linkify.py::test_prevent_links[callback1-a tests/test_linkify.py::test_prevent_links[callback2-a tests/test_linkify.py::test_prevent_links[callback3-a tests/test_linkify.py::test_prevent_links[callback4-a tests/test_linkify.py::test_prevent_links[callback5-a tests/test_linkify.py::test_set_attrs tests/test_linkify.py::test_only_proto_links tests/test_linkify.py::test_stop_email tests/test_linkify.py::test_tlds[example.com-<a tests/test_linkify.py::test_tlds[example.co-<a tests/test_linkify.py::test_tlds[example.co.uk-<a tests/test_linkify.py::test_tlds[example.edu-<a tests/test_linkify.py::test_tlds[example.xxx-<a tests/test_linkify.py::test_tlds[bit.ly/fun-<a tests/test_linkify.py::test_tlds[example.yyy-example.yyy] tests/test_linkify.py::test_tlds[brie-brie] tests/test_linkify.py::test_escaping tests/test_linkify.py::test_nofollow_off tests/test_linkify.py::test_link_in_html tests/test_linkify.py::test_links_https tests/test_linkify.py::test_add_rel_nofollow tests/test_linkify.py::test_url_with_path tests/test_linkify.py::test_link_ftp tests/test_linkify.py::test_link_query tests/test_linkify.py::test_link_fragment tests/test_linkify.py::test_link_entities tests/test_linkify.py::test_escaped_html tests/test_linkify.py::test_link_http_complete tests/test_linkify.py::test_non_url tests/test_linkify.py::test_javascript_url tests/test_linkify.py::test_unsafe_url tests/test_linkify.py::test_skip_tags tests/test_linkify.py::test_libgl tests/test_linkify.py::test_end_of_sentence[example.com-.] tests/test_linkify.py::test_end_of_sentence[example.com-...] tests/test_linkify.py::test_end_of_sentence[ex.com/foo-.] tests/test_linkify.py::test_end_of_sentence[ex.com/foo-....] tests/test_linkify.py::test_end_of_clause tests/test_linkify.py::test_sarcasm tests/test_linkify.py::test_wrapping_parentheses[(example.com)-expected_data0] tests/test_linkify.py::test_wrapping_parentheses[(example.com/)-expected_data1] tests/test_linkify.py::test_wrapping_parentheses[(example.com/foo)-expected_data2] tests/test_linkify.py::test_wrapping_parentheses[(((example.com/))))-expected_data3] tests/test_linkify.py::test_wrapping_parentheses[example.com/))-expected_data4] tests/test_linkify.py::test_wrapping_parentheses[(foo tests/test_linkify.py::test_wrapping_parentheses[http://en.wikipedia.org/wiki/Test_(assessment)-expected_data7] tests/test_linkify.py::test_wrapping_parentheses[(http://en.wikipedia.org/wiki/Test_(assessment))-expected_data8] tests/test_linkify.py::test_wrapping_parentheses[((http://en.wikipedia.org/wiki/Test_(assessment))-expected_data9] tests/test_linkify.py::test_wrapping_parentheses[(http://en.wikipedia.org/wiki/Test_(assessment)))-expected_data10] tests/test_linkify.py::test_wrapping_parentheses[(http://en.wikipedia.org/wiki/)Test_(assessment-expected_data11] tests/test_linkify.py::test_wrapping_parentheses[hello tests/test_linkify.py::test_parentheses_with_removing tests/test_linkify.py::test_ports[http://foo.com:8000-expected_data0] tests/test_linkify.py::test_ports[http://foo.com:8000/-expected_data1] tests/test_linkify.py::test_ports[http://bar.com:xkcd-expected_data2] tests/test_linkify.py::test_ports[http://foo.com:81/bar-expected_data3] tests/test_linkify.py::test_ports[http://foo.com:-expected_data4] tests/test_linkify.py::test_ports[http://foo.com:\u0663\u0669/-expected_data5] tests/test_linkify.py::test_ports[http://foo.com:\U0001d7e0\U0001d7d8/-expected_data6] tests/test_linkify.py::test_ignore_bad_protocols tests/test_linkify.py::test_link_emails_and_urls tests/test_linkify.py::test_links_case_insensitive tests/test_linkify.py::test_elements_inside_links tests/test_linkify.py::test_drop_link_tags tests/test_linkify.py::test_naughty_unescaping[&lt;br&gt;-&lt;br&gt;] tests/test_linkify.py::test_naughty_unescaping[&lt;br&gt; tests/test_linkify.py::test_hang tests/test_linkify.py::test_hyphen_in_mail tests/test_linkify.py::test_url_re_arg tests/test_linkify.py::test_email_re_arg tests/test_linkify.py::test_recognized_tags_arg tests/test_linkify.py::test_linkify_idempotent tests/test_linkify.py::TestLinkify::test_no_href_links tests/test_linkify.py::TestLinkify::test_rel_already_there tests/test_linkify.py::TestLinkify::test_only_text_is_linkified tests/test_linkify.py::test_linkify_filter[abc-abc] tests/test_linkify.py::test_linkify_filter[example.com-<a tests/test_linkify.py::test_linkify_filter[http://example.com?b=1&c=2-<a tests/test_linkify.py::test_linkify_filter[link:
bleach/sanitizer.py
bleach/sanitizer.py