That section is there to workaround limitations in Adobe Digital Editions, which tends to fall over and die with fragment identifiers that contain characters other than those in the regex, as is noted in the comment.
Not to mention that the cleanup is performed for fragment identifiers in the NCX ToC, for which the HTML spec is irrelevant.
|