cscott / codex-blackboard

Meteor app for coordinating solving for our MIT Mystery Hunt team
GNU Affero General Public License v3.0
1 stars 1 forks source link

url autolinker does funny things #6

Open cscott opened 3 years ago

cscott commented 3 years ago
bot: set the link for XYZ to http://cscott.net

response is:

The link for XYZ is now "https://cscott.net";.

Note the trailing semicolon.

Apparently (I'm guessing) the raw HTML is emitted as ...cscott.net".

And the URL autolinker snarfs up the &quot into the URL but leaves the ; on the floor, resulting in <a href="...cscott.net&quot">...cscott.net&quot</a>; and then HTML helpfully fills in the missing semicolons on the entities, leaving the trailing semicolon stranded.

Dunno what the best fix is here. Teach the URL autolinker about quoted strings, and if the URL starts with " then kick a " out of the end of it? That's roughly how parentheses are handled, I think...

Technically the autolinker shouldn't break the entity, so if it grabs the &quot part it should gobble up the semicolon as well. Ie semicolon shouldn't be a stop character after an ampersand. But that would still lead to issues, since I don't actually want the trailing quote included in the URL. But if it decoded entities before looking for stop characters, that would probably work. The rules for interpreting & in URLs are tricky, though...

Torgen commented 3 years ago

This is probably incidentally fixed by Torgen#412 which replaced the cleanup logic that generated a SafeString of HTML with parsing chunks out of the raw text that are rendered with Template.dynamic.