Skip to content

[FIX] Parsing messages with multiple markdown matches ignore some tokens#9884

Merged
rodrigok merged 2 commits intoRocketChat:developfrom
c0dzilla:parse
Feb 26, 2018
Merged

[FIX] Parsing messages with multiple markdown matches ignore some tokens#9884
rodrigok merged 2 commits intoRocketChat:developfrom
c0dzilla:parse

Conversation

@c0dzilla
Copy link
Copy Markdown
Contributor

@c0dzilla c0dzilla commented Feb 24, 2018

@RocketChat/core

Closes #9854 #9758

The message body was containing a random string of the form '=!=randomInteger=!=' many times whenever the message had multiple markdown matches(for example a url with inline code). This was because the tokens were being unmounted in the order in which they were attached during parsing, leading to misses when a token was overwritten by another token as in the case of mutiple matches. This pr changes unmounting order to LIFO to fix this.

Example:

parse-wrong

now parsed as

parse-correct

@rodrigok
Copy link
Copy Markdown
Member

Thanks @c0dzilla

What do you think about use reverse to keep the code cleaner?

example:

- for (const {token, text} of message.tokens) {
+ for (const {token, text} of message.tokens.reverse()) {

@c0dzilla
Copy link
Copy Markdown
Contributor Author

@rodrigok I've made the change.

@rodrigok rodrigok added this to the 0.62.0 milestone Feb 26, 2018
@rodrigok rodrigok changed the title [FIX] Parsing messages with multiple markdown matches [FIX] Parsing messages with multiple markdown matches ignore some tokens Feb 26, 2018
@rodrigok rodrigok merged commit 5033cab into RocketChat:develop Feb 26, 2018
@rodrigok rodrigok mentioned this pull request Feb 28, 2018
@DeanVanGreunen
Copy link
Copy Markdown

Thanks for fixing Guys 🥇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Big/Small Markdown Display Bug (could contain a great new feature)

4 participants