Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pasting specific text in multi-line quote causing that specific room to crash #6814

Closed
josephmarksjr opened this issue Apr 26, 2017 · 15 comments · Fixed by josephmarksjr/Rocket.Chat#1

Comments

@josephmarksjr
Copy link

josephmarksjr commented Apr 26, 2017

Rocket.Chat Version: v54
Running Instances: 1
DB Replicaset OpLog: Enabled
Runtime_Environment
Node Version: v4.5.0
Build_Environment
Node version: v4.7.3

I noticed an odd bug that can cripple any private or group chat. I copied and pasted a message someone sent, in order to sent it to someone else. I also wrapped it in ``` to form a multi-level quote.

Reproduce this by pasting the following test and wrapping it with ```:
I ....

When you send this, the chat page hangs and eventually you can't do anything. In Chrome it will eventually ask you to kill the page.

When you come back to RC (you'll have to manually go to a different url, such as a different dm or chat) and go back to the previous chat, it won't load or it won't let you send messages.

I was also able to reproduce this at http://demo.rocket.chat.

josephmarksjr added a commit to josephmarksjr/Rocket.Chat that referenced this issue Apr 26, 2017
Reverted the multiline code block regular expression to the way it was before commit e2ea464.  I believe this introduced the (potentially crippling) bug in Issue RocketChat#6814.
@geekgonecrazy geekgonecrazy reopened this Apr 26, 2017
@geekgonecrazy
Copy link
Member

geekgonecrazy commented Apr 26, 2017

Confirmed this for sure brings down the browser.

```I .... ```

And it immediately locks up the entire window.

Also renders that channel completely useless until its removed directly from the db

@geekgonecrazy
Copy link
Member

Can reproduce with as little as ```U ..``` a single dot is no issue. 2 or more breaks it

@geekgonecrazy
Copy link
Member

geekgonecrazy commented Apr 27, 2017

Traced it down to: https://github.com/RocketChat/Rocket.Chat/blob/develop/packages/rocketchat-markdown/markdowncode.js#L81
If you feed it: I .. doing something like: hljs.highlightAuto(('I ..')) everything locks up

@geekgonecrazy
Copy link
Member

Created an issue: highlightjs/highlight.js#1505

@geekgonecrazy
Copy link
Member

geekgonecrazy commented Apr 29, 2017

Its been patched upstream: highlightjs/highlight.js@d05317a

Just need to wait on a release or reference the commit. 👍

@josephmarksjr
Copy link
Author

@geekgonecrazy We're still waiting on a release from highlight.js. How would we reference the commit?

@josephmarksjr
Copy link
Author

It looks like this was fixed in 9.12.0. How long till we see that reflected in RC? Will we have to wait for a RC update?

@geekgonecrazy
Copy link
Member

@josephmarksjr i've updated my PR and will try and get it merged. Soon as its merged it'll be available in in develop. Then of course be available in the next release candidate and subsequent release.

@tanc
Copy link

tanc commented Jun 5, 2017

This is currently biting us (I think). One of our channels is not accessible. Is there any way to manually add the needed library update on an existing release?

@geekgonecrazy
Copy link
Member

@tanc unfortunately its something that's compiled in on releases. Easiest way to correct this is to remove the message from the database unfortunately :(

@tanc
Copy link

tanc commented Jun 6, 2017

No problem @geekgonecrazy, I managed to use the REST API to delete the latest messages on that channel which freed it up and allowed us to connect again. Thanks for fixing this issue though and look forward to the next release!

@admin-crowd-iugo
Copy link

this is how we fixed it
use rocketchat
db.rocketchat_oembed_cache.count();
db.getCollection('rocketchat_oembed_cache').drop();
show collections;
db.rocketchat_message.remove({"_id": "BzRdoqy2Fec6meusS"},true);
db.rocketchat_message.find( { "_id": "BzRdoqy2Fec6meusS" } );
db.rocketchat_message.find( { rid: "u8Gg7jjTPu58JwXR7" } ).limit(10);
rs.status();
show databases;
db.migrations.find().pretty()
db.rocketchat_message.update({"_id": "96keZ44ohJKnf8i4d"}, { $set: { "msg": "deleted"}}, false, false);

@geekgonecrazy
Copy link
Member

For any others that find this. Please do not blindly copy and paste the above.

To fix the issue you would not need to drop oembed cache. You would have to find the offending message and prune it. using:

db.rocketchat_message.remove({"_id": "[message_id here]"},true);

@morrison23
Copy link

morrison23 commented Mar 6, 2018

Just thought I'd comment - ran into this issue today and the above helped me resolve.

My instance is running inside a docker container here are the specific steps I used:

docker exec -it <your mongoContainer> mongo
(the above launches the mongo shell from inside docker)
show databases;
use rocketchat
db.rocketchat_message.find().sort({ ts: -1 });
(the above will list new messages starting with the newest; type 'it' to page; find the _id of the bad msg)
db.rocketchat_message.find({_id: "<your message id here>"});
(the above is a good check to make sure you've got the id and syntax correct)
db.rocketchat_message.remove({_id: "<your message id here>"},true);

MogoDB Shell Reference

Hope that helps someone!

@geekgonecrazy
Copy link
Member

Thanks for sharing the tips!

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