justintv / Twitch-API

A home for details about our API
www.twitch.tv
1.72k stars 381 forks source link

Chat embed crashes browser #499

Closed EmersonGGS closed 8 years ago

EmersonGGS commented 8 years ago

The regex for emberchat.js (^https?:\/\/([a-zA-Z0-9]+.)twitch.tv(:[0-9]+)?\/.$) times out and crashes browsers with a lengthy url.

example url: https://someReallyLongUrl.someReallyLongUrl.com/someReallyLongUrl?someReallyLongUrl=someReallyLongUrl

related: #492

jzisser9 commented 8 years ago

Hey @EmersonGGS, glad you were able to discover the cause of this. That makes a lot of sense - my URL definitely gets lengthy the more streamers I display in the page.

jzisser9 commented 8 years ago

Can confirm that shortening my URL when attempting to load the chat frame eliminates the browser crash.

cjardine commented 8 years ago

This is a problem, not everyone has the option of simply shortening their url.

Here is an example of the code used by Twitch evaluating the scenario of the OP. Luckily the site where this is posted catches the error but you can see how it is unable to complete evaluating do to the poorly crafted expression.

http://regexr.com/3cr1v

jzisser9 commented 8 years ago

@cjardine, agreed. And shortening my site's URL creates its own problems.

FugiTech commented 8 years ago

This was fixed on Feb 16th