Possible bug in parsing parameters

10 views
Skip to first unread message

zzing

unread,
Aug 15, 2012, 3:42:34 AM8/15/12
to clck...@googlegroups.com

The code:       setBaseURI      str = let Just (URI {uriAuthority = Just (URIAuth {uriRegName = host, uriPort = port})}) = parseAbsoluteURI str in
                            ModifyConfig $ \c -> c { clckHostname = host, clckPort = read port }


will cause an exception on "read port"

as demonstrated:

let Just (URI {uriAuthority = Just (URIAuth {uriRegName = host, uriPort = port})}) = parseAbsoluteURI "http://socr.uwindsor.ca/socr"
Prelude Network.URI> port
""
Prelude Network.URI> (read "")::Integer
*** Exception: Prelude.read: no parse



and

> let Just (URI {uriAuthority = Just (URIAuth {uriRegName = host, uriPort = port})}) = parseAbsoluteURI "http://socr.uwindsor.ca:443"
Prelude Network.URI> uriRegName
Prelude Network.URI> host
"socr.uwindsor.ca"
Prelude Network.URI> port
":443"
Prelude Network.URI> (read ":443")::Integer
*** Exception: Prelude.read: no parse


This is occurring when I am running the installed version. I am just replacing the appropriate code with 8000 for now.

read can throw exceptions, so something else would be better.
Reply all
Reply to author
Forward
0 new messages