|
|
|
@ -120,26 +120,44 @@ isFull jid = not $ isBare jid |
|
|
|
-- Parses an JID string and returns its three parts. It performs no |
|
|
|
-- Parses an JID string and returns its three parts. It performs no |
|
|
|
-- validation or transformations. We are using Parsec to parse the |
|
|
|
-- validation or transformations. We are using Parsec to parse the |
|
|
|
-- JIDs. There is no input for which 'jidParts' fails. |
|
|
|
-- JIDs. There is no input for which 'jidParts' fails. |
|
|
|
jidParts :: AP.Parser (Maybe Text, Text, Maybe Text) |
|
|
|
|
|
|
|
jidParts = do |
|
|
|
jidParts = do |
|
|
|
a <- firstPartP |
|
|
|
-- Read until we reach an '@', a '/', or EOF. |
|
|
|
b <- Just <$> domainPartP <|> (return Nothing) |
|
|
|
a <- AP.takeWhile1 (AP.notInClass ['@', '/']) |
|
|
|
c <- Just <$> resourcePartP <|> (return Nothing) |
|
|
|
-- Case 1: We found an '@', and thus the localpart. At least the |
|
|
|
case (a,b,c) of |
|
|
|
-- domainpart is remaining. Read the '@' and until a '/' or EOF. |
|
|
|
-- Whether or not we have a resource part, if there is no "@" |
|
|
|
do |
|
|
|
-- x is the domain |
|
|
|
b <- domainPartP |
|
|
|
(x, Nothing, z) -> return (Nothing, x, z) |
|
|
|
-- Case 1A: We found a '/' and thus have all the JID parts. Read |
|
|
|
-- When we do have an "@", x is the localpart |
|
|
|
-- the '/' and until EOF. |
|
|
|
(x, Just y, z) -> return (Just x, y, z) |
|
|
|
do |
|
|
|
|
|
|
|
c <- resourcePartP -- Parse resourcepart |
|
|
|
firstPartP = AP.takeWhile1 (AP.notInClass ['@', '/']) |
|
|
|
return (Just a, b, Just c) |
|
|
|
domainPartP = do |
|
|
|
-- Case 1B: We have reached EOF; the JID is in the form |
|
|
|
|
|
|
|
-- localpart@domainpart. |
|
|
|
|
|
|
|
<|> do |
|
|
|
|
|
|
|
AP.endOfInput |
|
|
|
|
|
|
|
return (Just a, b, Nothing) |
|
|
|
|
|
|
|
-- Case 2: We found a '/'; the JID is in the form |
|
|
|
|
|
|
|
-- domainpart/resourcepart. |
|
|
|
|
|
|
|
<|> do |
|
|
|
|
|
|
|
b <- resourcePartP |
|
|
|
|
|
|
|
AP.endOfInput |
|
|
|
|
|
|
|
return (Nothing, a, Just b) |
|
|
|
|
|
|
|
-- Case 3: We have reached EOF; we have an JID consisting of only |
|
|
|
|
|
|
|
-- a domainpart. |
|
|
|
|
|
|
|
<|> do |
|
|
|
|
|
|
|
AP.endOfInput |
|
|
|
|
|
|
|
return (Nothing, a, Nothing) |
|
|
|
|
|
|
|
where |
|
|
|
|
|
|
|
domainPartP = do |
|
|
|
_ <- AP.char '@' |
|
|
|
_ <- AP.char '@' |
|
|
|
AP.takeWhile1 (/= '/') |
|
|
|
AP.takeWhile1 (/= '/') |
|
|
|
resourcePartP = do |
|
|
|
resourcePartP = do |
|
|
|
_ <- AP.char '/' |
|
|
|
_ <- AP.char '/' |
|
|
|
AP.takeText |
|
|
|
AP.takeText |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nodeprepProfile :: SP.StringPrepProfile |
|
|
|
nodeprepProfile :: SP.StringPrepProfile |
|
|
|
nodeprepProfile = SP.Profile |
|
|
|
nodeprepProfile = SP.Profile |
|
|
|
{ SP.maps = [SP.b1, SP.b2] |
|
|
|
{ SP.maps = [SP.b1, SP.b2] |
|
|
|
|