matrix-org / matrix-appservice-irc

Node.js IRC bridge for Matrix
Apache License 2.0
460 stars 149 forks source link

missing closing ^Q on inline code markdown #1770

Open emorrp1 opened 10 months ago

emorrp1 commented 10 months ago

Sent with flatpak Element: 1.11.33 to OFTC BridgeVersion: 1.0.1 in markdown composer, the relevant code seems to be formatting.ts. Reporting because I'd like to not annoy IRC users (having recently been bitten by pastebin behaviour change).

10/08/2023, 08:17:52 - emorrp1: TIL (via #licenses) a thorough description/animation of catastrophic regex backtracking "x=x" with /.*.*=.*/ and fixing with state automata https://blog.cloudflare.com/details-of-the-cloudflare-outage-on-july-2-2019/#appendix-about-regular-expression-backtracking 10/08/2023, 08:23:21 - _jwilk: BTW, I wonder it's my or emorrp1's IRC client misbehaving, because there's only one ^Q in that message. 10/08/2023, 08:25:25 - emorrp1: it'll be mine (markdown maybe?), not yours, but what's a ^Q? 10/08/2023, 08:25:42 - _jwilk: https://modern.ircdocs.horse/formatting.html#monospace 10/08/2023, 08:25:46 - Unit193: _jwilk: It's a common Matrix thing. 10/08/2023, 08:26:50 - _jwilk: Unit193: So no hope it will be ever fixed? :] 10/08/2023, 08:27:12 - Unit193: That's how it goes.

{
  "type": "m.room.message",
  "sender": "@emorrp1:freedombox.emorrp1.name",
  "content": {
    "msgtype": "m.text",
    "body": "TIL (via #licenses) a thorough description/animation of catastrophic regex backtracking `\"x=x\" with /.*.*=.*/` and fixing with state automata https://blog.cloudflare.com/details-of-the-cloudflare-outage-on-july-2-2019/#appendix-about-regular-expression-backtracking",
    "format": "org.matrix.custom.html",
    "formatted_body": "TIL (via #licenses) a thorough description/animation of catastrophic regex backtracking <code>\"x=x\" with /.*.*=.*/</code> and fixing with state automata https://blog.cloudflare.com/details-of-the-cloudflare-outage-on-july-2-2019/#appendix-about-regular-expression-backtracking"
  },
  "event_id": "$169165187216UHnGX:freedombox.emorrp1.name",
  "origin_server_ts": 1691651872129,
  "unsigned": {
    "age": 963,
    "transaction_id": "m1691651871635.528"
  },
  "room_id": "!YKqCOOCDNoKQrdYRlj:matrix.org"
}
Half-Shot commented 10 months ago

I was unable to reproduce when testing, and we do have a unit test for this one. Very odd.

jwilk commented 10 months ago

The trouble is that Matrix uses ^Q (\u0011) to start monospace, but ^O (\u000F) to end it. Irssi before 1.4.4 (https://github.com/irssi/irssi/pull/1442) didn't support ^Q (it would show up as Q with inverted colors), but it did support ^O. So if you have an old Irssi (like me), you see only where monospace was supposed to start, but not where it was supposed to end.