As a horrible hack, going into element.py and special-casing for `href` attributes makes things work, through it's probably super buggy:
```
for key, val in attributes:
if val is None: decoded = key
else:
if isinstance(val, list) or isinstance(val, tuple): val = ' '.join(val) elif not isinstance(val, str): val = str(val) elif ( isinstance(val, AttributeValueWithCharsetSubstitution) and eventual_encoding is not None
): val = val.encode(eventual_encoding)
text = formatter.attribute_value(val) decoded = ( str(key) + '=' + formatter.quoted_attribute_value(text)) attrs.append(decoded)
close = ''
closeTag = ''
```
to
```
for key, val in attributes:
if val is None: decoded = key
else:
if isinstance(val, list) or isinstance(val, tuple): val = ' '.join(val) elif not isinstance(val, str): val = str(val) elif ( isinstance(val, AttributeValueWithCharsetSubstitution) and eventual_encoding is not None
): val = val.encode(eventual_encoding)
if key == 'href': text = str(val) else: text = formatter.attribute_value(val) decoded = ( str(key) + '=' + formatter.quoted_attribute_value(text)) attrs.append(decoded)
close = ''
closeTag = ''
```
The core of the issue appears to be that the "minimal" EntitySubstitution() instance still replaces "&".
I have no idea what's "correct" from a spec perspective here, but I can say that it seems BS4 is unable to generate the valid HTML output I need here, and I don't *think* having multi-parameter query strings in a anchor tag is invalid in any variant of HTML.
As a horrible hack, going into element.py and special-casing for `href` attributes makes things work, through it's probably super buggy:
```
decoded = key
val = ' '.join(val)
elif not isinstance(val, str):
val = str(val)
elif (
isinstance( val, AttributeValueW ithCharsetSubst itution)
and eventual_encoding is not None
val = val.encode( eventual_ encoding)
for key, val in attributes:
if val is None:
else:
if isinstance(val, list) or isinstance(val, tuple):
):
close = ''
closeTag = ''
```
to
```
decoded = key
val = ' '.join(val)
elif not isinstance(val, str):
val = str(val)
elif (
isinstance( val, AttributeValueW ithCharsetSubst itution)
and eventual_encoding is not None
val = val.encode( eventual_ encoding)
text = str(val)
else:
text = formatter. attribute_ value(val)
decoded = (
str( key) + '='
+ formatter. quoted_ attribute_ value(text) )
attrs. append( decoded)
for key, val in attributes:
if val is None:
else:
if isinstance(val, list) or isinstance(val, tuple):
):
if key == 'href':
close = ''
closeTag = ''
```
The core of the issue appears to be that the "minimal" EntitySubstitut ion() instance still replaces "&".
I have no idea what's "correct" from a spec perspective here, but I can say that it seems BS4 is unable to generate the valid HTML output I need here, and I don't *think* having multi-parameter query strings in a anchor tag is invalid in any variant of HTML.