diff --git a/source/Network/Xmpp/Types.hs b/source/Network/Xmpp/Types.hs index d0675dd..10f064c 100644 --- a/source/Network/Xmpp/Types.hs +++ b/source/Network/Xmpp/Types.hs @@ -894,16 +894,19 @@ instance Read Jid where readsPrec _ s = do -- Verifies that the first word is "parseJid", parses the second word and -- the remainder, if any, and produces these two values or fails. - let (s', r) = case lex s of - [] -> error "Expected `parseJid \"\"'" - [("parseJid", r')] -> case lex r' of - [] -> error "Expected `parseJid \"\"'" - [(s'', r'')] -> (s'', r'') - _ -> error "Expected `parseJid \"\"'" - _ -> error "Expected `parseJid \"\"'" - -- Read the JID string (removes the quotes), validate, and return. - [(parseJid (read s' :: String), r)] -- May fail with "Prelude.read: no parse" - -- or the `parseJid' error message (see below) + case lex s of + [("parseJid", r')] -> + case lex r' of + [(s', r'')] -> + case (reads s') of + ((jidTxt,_):_) -> + case jidFromText (Text.pack jidTxt) of + Nothing -> [] + Just jid' -> [(jid', r'')] + _ -> [] + _ -> [] + _ -> [] + #if WITH_TEMPLATE_HASKELL