We should stop processing a DOI when we see an important URL character -- e.g. "?", "&" or "#".
Still there are some DOIs that have these characters in them. e.g. 10.1002/(SICI)1097-0142(19960401)77:7<1356::AID-CNCR20>3.0.CO;2-#
But most of the time it's because we're processing a messy URL.