JavaChat / OakBot

A Java-based chat bot for Stackoverflow Chat
45 stars 32 forks source link

/learn gives incorrect response #36

Closed Jenna1337 closed 6 years ago

Jenna1337 commented 7 years ago

The command /learn formattest2 \\*_test_* prints out the plain text "\*test**" instead of "\*test\"

Jenna1337 commented 7 years ago

The conversation: https://chat.stackoverflow.com/rooms/138769/conversation/oakbot-bug

mangstadt commented 7 years ago

I looks like this is due to a quirk in the way Stack Overflow Chat converts Markdown to HTML. OakBot appears to be correctly converting the HTML of the message to Markdown. In fact, if you manually post OakBot's HTML-to-Markdown conversion (\\**test*\*) into the chat, the message is briefly displayed with the italic formatting, and then the italics are removed after a few moments. This suggests that the SO Chat client code and SO Chat server code have slightly different Markdown-to-HTML conversion algorithms.

Another interesting side-note is that using asterisks instead of underscores produces a slightly different result.

Test 1 Entered by user: \\*_test_* Converted to HTML by SO Chat: \*<i>test</i>* Converted back to Markdown by OakBot: \\**test*\*

Test 2 Entered by user: \\**test** Converted to HTML by SO Chat: \*<i>test*</i> Converted back to Markdown by OakBot: \\**test\**

Jenna1337 commented 6 years ago

You know you can get the plain text the user entered by appending ?plain=true to the message url, right? e.g., https://chat.stackoverflow.com/message/38120049?plain=true

mangstadt commented 6 years ago

Thanks @Jenna3715! Didn't know about that!

Fixed in a7c3284a03fa70b677b9c90f3812c02a2ea60bcc.