on master help sign in
Merge pull request #142 from ilyakooo0/develop
30038c0iko
Procfile+1−1
@@ -1 +1 @@
1−web: denis-exe +RTS -N -T
1+web: denis-exe +RTS -N
denis/src/Data/Limits.hs+5−2
@@ -14,7 +14,7 @@ maxMessageLimitName :: Int
14maxMessageLimitName = 60
14maxMessageLimitName = 60
15
15
16postElementLengthLimit :: Int
16postElementLengthLimit :: Int
17−postElementLengthLimit = 10000
17+postElementLengthLimit = 35000
18
18
19userFieldLengthLimit :: Int
19userFieldLengthLimit :: Int
20userFieldLengthLimit = 50
20userFieldLengthLimit = 50
@@ -26,4 +26,7 @@ channelCountLimit :: Int64
26channelCountLimit = 128
26channelCountLimit = 128
27
27
28listLimit :: Int
28listLimit :: Int
29−listLimit = 100
29+listLimit = 100
30+
31+globalTextLimit :: Int
32+globalTextLimit = 50000
denis/src/Data/Text/Validator.hs+5−20
@@ -12,8 +12,11 @@ module Data.Text.Validator (
12
12
13import qualified Data.Text as T
13import qualified Data.Text as T
14import Data.Char
14import Data.Char
15+import Data.Limits
15
16
16isValidChar :: Char -> Bool
17isValidChar :: Char -> Bool
18+isValidChar '\n' = True
19+isValidChar '\r' = True
17isValidChar = isPrint
20isValidChar = isPrint
18
21
19class HasValidatableText t where
22class HasValidatableText t where
@@ -29,16 +32,6 @@ instance (HasValidatableText t) => HasValidatableText (ExtraPredicate t) where
29 validateText (t `ExtraPredicate` p) = validateText t && p t
32 validateText (t `ExtraPredicate` p) = validateText t && p t
30
33
31
34
32−
33−-- instance (Traversable f) => HasValidatableText (RangeableText (ExtraPredicate (f String))) where
34−-- validateText ((t `ExtraPredicate` p) `RangeableText` lims) = p t && validateText (t `RangeableText` lims)
35−
36−-- instance HasValidatableText (RangeableText (ExtraPredicate (f T.Text))) where
37−-- validateText ((t `ExtraPredicate` p) `RangeableText` lims) = p t && validateText (t `RangeableText` lims)
38−
39−-- instance (Foldable f) => HasValidatableText (RangeableText (ExtraPredicate (f T.Text))) where
40−-- validateText ((t `ExtraPredicate` p) `RangeableText` lims) = p t && validateText (t `RangeableText` lims)
41−
42infixl 5 ~<
35infixl 5 ~<
43(~<) :: t -> Int -> RangeableText t
36(~<) :: t -> Int -> RangeableText t
44t ~< n = t <~> (0, n)
37t ~< n = t <~> (0, n)
@@ -59,16 +52,8 @@ instance HasValidatableText (RangeableText T.Text) where
59 where
52 where
60 len = T.length t
53 len = T.length t
61
54
62−-- instance HasValidatableText (RangeableText T.Text) where
63−-- validateText (t `RangeableText` (lower, upper)) = len >= lower && len <= upper
64−-- where
65−-- len = T.length t
66−
67−-- instance (Traversable t, HasValidatableText v) => HasValidatableText (t v) where
68−-- validateText = all validateText
69−
70instance HasValidatableText T.Text where
55instance HasValidatableText T.Text where
71− validateText t = T.all isValidChar t && (not . T.null) t
56+ validateText t = T.all isValidChar t && (not . T.null) t && T.length t < globalTextLimit
72
57
73instance HasValidatableText String where
58instance HasValidatableText String where
74− validateText t = all isValidChar t && length t > 0
59+ validateText t = all isValidChar t && length t > 0 && length t < globalTextLimit