dont crash on bad input
This commit is contained in:
parent
8f8650fd69
commit
1e035337de
|
@ -193,25 +193,27 @@ function inferServerUrl(url as string) as string
|
||||||
end for
|
end for
|
||||||
handled = 0
|
handled = 0
|
||||||
timeout = CreateObject("roTimespan")
|
timeout = CreateObject("roTimespan")
|
||||||
while timeout.totalseconds() < 15
|
if hosts.count() > 0
|
||||||
resp = wait(0, port)
|
while timeout.totalseconds() < 15
|
||||||
if type(resp) = "roUrlEvent"
|
resp = wait(0, port)
|
||||||
' TODO
|
if type(resp) = "roUrlEvent"
|
||||||
' if response code is a 300 redirect then we should return the redirect url
|
' TODO
|
||||||
' Make sure this happens or make it happen
|
' if response code is a 300 redirect then we should return the redirect url
|
||||||
if resp.GetResponseCode() = 200 and isJellyfinServer(resp.GetString())
|
' Make sure this happens or make it happen
|
||||||
selectedUrl = hosts.lookup(resp.GetSourceIdentity().ToStr())
|
if resp.GetResponseCode() = 200 and isJellyfinServer(resp.GetString())
|
||||||
print "Successfully inferred server URL: " selectedUrl
|
selectedUrl = hosts.lookup(resp.GetSourceIdentity().ToStr())
|
||||||
return selectedUrl
|
print "Successfully inferred server URL: " selectedUrl
|
||||||
|
return selectedUrl
|
||||||
|
end if
|
||||||
end if
|
end if
|
||||||
end if
|
handled += 1
|
||||||
handled += 1
|
if handled = reqs.count()
|
||||||
if handled = reqs.count()
|
print "inferServerUrl in utils/misc.brs failed to find a server from the string " url " but did not timeout."
|
||||||
print "inferServerUrl in utils/misc.brs failed to find a server from the string " url " but did not timeout."
|
return ""
|
||||||
return ""
|
end if
|
||||||
end if
|
end while
|
||||||
end while
|
print "inferServerUrl in utils/misc.brs failed to find a server from the string " url " because it timed out."
|
||||||
print "inferServerUrl in utils/misc.brs failed to find a server from the string " url " because it timed out."
|
end if
|
||||||
return ""
|
return ""
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
@ -225,6 +227,8 @@ function urlCandidates(input as string)
|
||||||
' a proto wasn't declared
|
' a proto wasn't declared
|
||||||
url = parseUrl("none://" + input)
|
url = parseUrl("none://" + input)
|
||||||
end if
|
end if
|
||||||
|
' if the proto is still invalid then the string is not valid
|
||||||
|
if url[1] = invalid then return []
|
||||||
proto = url[1]
|
proto = url[1]
|
||||||
host = url[2]
|
host = url[2]
|
||||||
port = url[3]
|
port = url[3]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user