mirror of
https://github.com/simplex-chat/simplexmq.git
synced 2026-11-23 04:40:27 +00:00
lib, ntf server: reject null byte in host and server without key hash (#2027)
* core: reject empty server key hash and null byte in host * core: reject notification subscription to a server without key hash * lib: exclude null byte in host with the other excluded characters * tests: name the subscription server address test by the rejected values
This commit is contained in:
1 parent
5f914a040e
commit
e8aff94ca9
4 files changed
+26
-2
No files matched your search
@@ -384,9 +384,13 @@ data SMPQueueNtf = SMPQueueNtf
|
||||
instance Encoding SMPQueueNtf where
|
||||
smpEncode SMPQueueNtf {smpServer, notifierId} = smpEncode (smpServer, notifierId)
|
||||
smpP = do
|
||||
smpServer <- updateSMPServerHosts <$> smpP
|
||||
smpServer <- updateSMPServerHosts <$> (requireKeyHash <$?> smpP)
|
||||
notifierId <- smpP
|
||||
pure SMPQueueNtf {smpServer, notifierId}
|
||||
where
|
||||
requireKeyHash srv
|
||||
| B.null (C.unKeyHash (keyHash srv)) = Left "SMP server without key hash"
|
||||
| otherwise = Right srv
|
||||
|
||||
instance StrEncoding SMPQueueNtf where
|
||||
strEncode SMPQueueNtf {smpServer, notifierId} = strEncode smpServer <> "/" <> strEncode notifierId
|
||||
|
||||
@@ -89,7 +89,7 @@ instance StrEncoding TransportHost where
|
||||
[ THIPv4 <$> ((,,,) <$> ipNum <*> ipNum <*> ipNum <*> A.decimal),
|
||||
maybe (Left "bad IPv6") (Right . THIPv6 . fromIPv6w) . readMaybe . B.unpack <$?> ipv6StrP,
|
||||
THOnionHost <$> ((<>) <$> A.takeWhile (\c -> isAsciiLower c || isDigit c) <*> A.string ".onion"),
|
||||
THDomainName . B.unpack <$> (notOnion <$?> A.takeWhile1 (A.notInClass ":#,;/ \n\r\t[]"))
|
||||
THDomainName . B.unpack <$> (notOnion <$?> A.takeWhile1 (A.notInClass ":#,;/ \n\r\t[]\0"))
|
||||
]
|
||||
where
|
||||
ipNum = validIP <$?> (A.decimal <* A.char '.')
|
||||
|
||||
Reference in new issue
Block a user