In Safari, limit iterations of the command-parsing loop.

This commit is contained in:
Shane Kilkelly 2016-04-11 09:55:53 +01:00
parent 862057b32c
commit 4fd4a0372c

View file

@ -1,11 +1,30 @@
define [], () ->
browserIsSafari = () ->
userAgent = navigator.userAgent
(
userAgent.match(/.*Safari\/.*/) &&
!userAgent.match(/.*Chrome\/.*/) &&
!userAgent.match(/.*Chromium\/.*/)
)
class Parser
constructor: (@doc) ->
parse: () ->
limit = null
if browserIsSafari()
limit = 100
commands = []
seen = {}
iterations = 0
while command = @nextCommand()
iterations += 1
if limit && iterations > limit
return commands
docState = @doc
optionalArgs = 0