packages feed

modern-uri 0.3.4.3 → 0.3.4.4

raw patch · 4 files changed

+40/−21 lines, 4 filesdep ~criteriondep ~template-haskell

Dependency ranges changed: criterion, template-haskell

Files

CHANGELOG.md view
@@ -1,3 +1,8 @@+## Modern URI 0.3.4.4++* The `mailto` scheme does not escape `@` in its paths (fixes the regression+  introduced in 0.3.4.3).+ ## Modern URI 0.3.4.3  * Percent encode delimiter characters and `@` that appear in a path
Text/URI/Render.hs view
@@ -65,7 +65,7 @@ render' x =   equip     TLB.decimal-    (TLB.fromText . percentEncode)+    (TLB.fromText . percentEncode (uriScheme x))     (genericRender x)  -- | Render a given 'URI' value as a strict 'ByteString'.@@ -77,7 +77,7 @@ renderBs' x =   equip     BB.wordDec-    (BB.byteString . TE.encodeUtf8 . percentEncode)+    (BB.byteString . TE.encodeUtf8 . percentEncode (uriScheme x))     (genericRender x)  -- | Render a given 'URI' value as a 'String'.@@ -94,7 +94,7 @@   toShowS $     equip       (DString . showInt)-      (fromString . T.unpack . percentEncode)+      (fromString . T.unpack . percentEncode (uriScheme x))       (genericRender x)  ----------------------------------------------------------------------------@@ -230,11 +230,13 @@ percentEncode ::   forall l.   RLabel l =>+  -- | Scheme of the URI+  Maybe (RText 'Scheme) ->   -- | Input text to encode   RText l ->   -- | Percent-encoded text   Text-percentEncode rtxt =+percentEncode mscheme rtxt =   if skipEscaping (Proxy :: Proxy l) txt     then txt     else T.unfoldr f (TE.encodeUtf8 txt, [])@@ -254,7 +256,7 @@     encodeByte x = '%' :| [intToDigit h, intToDigit l]       where         (h, l) = fromIntegral x `quotRem` 16-    nne = needsNoEscaping (Proxy :: Proxy l)+    nne = needsNoEscaping (Proxy :: Proxy l) mscheme     sap = spaceAsPlus (Proxy :: Proxy l)     txt = unRText rtxt {-# INLINE percentEncode #-}@@ -264,7 +266,7 @@ class RLabel (l :: RTextLabel) where   -- | The predicate selects bytes that are not to be percent-escaped in   -- rendered URI.-  needsNoEscaping :: Proxy l -> Word8 -> Bool+  needsNoEscaping :: Proxy l -> Maybe (RText 'Scheme) -> Word8 -> Bool    -- | Whether to serialize space as the plus sign.   spaceAsPlus :: Proxy l -> Bool@@ -275,34 +277,41 @@   skipEscaping Proxy _ = False  instance RLabel 'Scheme where-  needsNoEscaping Proxy x = isAlphaNum x || x == 43 || x == 45 || x == 46+  needsNoEscaping Proxy _ x = isAlphaNum x || x == 43 || x == 45 || x == 46  instance RLabel 'Host where-  needsNoEscaping Proxy x = isUnreserved x || isDelim x+  needsNoEscaping Proxy _ x = isUnreserved x || isDelim x   skipEscaping Proxy x = T.take 1 x == "["  instance RLabel 'Username where-  needsNoEscaping Proxy x = isUnreserved x || isDelim x+  needsNoEscaping Proxy _ x = isUnreserved x || isDelim x  instance RLabel 'Password where-  needsNoEscaping Proxy x = isUnreserved x || isDelim x || x == 58+  needsNoEscaping Proxy _ x = isUnreserved x || isDelim x || x == 58  instance RLabel 'PathPiece where-  needsNoEscaping Proxy x =-    isUnreserved x+  needsNoEscaping Proxy mscheme x =+    case mscheme of+      Nothing -> commonCase+      Just scheme ->+        if unRText scheme == "mailto"+          then commonCase || x == 64+          else commonCase+    where+      commonCase = isUnreserved x  instance RLabel 'QueryKey where-  needsNoEscaping Proxy x =+  needsNoEscaping Proxy _ x =     isPChar isDelim' x || x == 47 || x == 63   spaceAsPlus Proxy = True  instance RLabel 'QueryValue where-  needsNoEscaping Proxy x =+  needsNoEscaping Proxy _ x =     isPChar isDelim' x || x == 47 || x == 63   spaceAsPlus Proxy = True  instance RLabel 'Fragment where-  needsNoEscaping Proxy x =+  needsNoEscaping Proxy _ x =     isPChar isDelim x || x == 47 || x == 63  isPChar :: (Word8 -> Bool) -> Word8 -> Bool
modern-uri.cabal view
@@ -1,11 +1,11 @@ cabal-version:   2.4 name:            modern-uri-version:         0.3.4.3+version:         0.3.4.4 license:         BSD-3-Clause license-file:    LICENSE.md maintainer:      Mark Karpov <markkarpov92@gmail.com> author:          Mark Karpov <markkarpov92@gmail.com>-tested-with:     ghc ==8.10.7 ghc ==9.0.1 ghc ==9.2.1+tested-with:     ghc ==8.10.7 ghc ==9.0.2 ghc ==9.2.1 homepage:        https://github.com/mrkkrp/modern-uri bug-reports:     https://github.com/mrkkrp/modern-uri/issues synopsis:        Modern library for working with URIs@@ -53,7 +53,7 @@         reflection >=2.0 && <3.0,         tagged >=0.8 && <0.9,         template-haskell >=2.10 && <2.19,-        text >=0.2 && <1.3+        text >=0.2 && <2.1      if flag(dev)         ghc-options: -Wall -Werror@@ -84,7 +84,7 @@         hspec-megaparsec >=2.0 && <3.0,         megaparsec >=8.0 && <10.0,         modern-uri,-        text >=0.2 && <1.3+        text >=0.2 && <2.1      if flag(dev)         ghc-options: -Wall -Werror@@ -103,7 +103,7 @@         criterion >=0.6.2.1 && <1.6,         megaparsec >=8.0 && <10.0,         modern-uri,-        text >=0.2 && <1.3+        text >=0.2 && <2.1      if flag(dev)         ghc-options: -O2 -Wall -Werror@@ -122,7 +122,7 @@         deepseq >=1.3 && <1.5,         megaparsec >=8.0 && <10.0,         modern-uri,-        text >=0.2 && <1.3,+        text >=0.2 && <2.1,         weigh >=0.0.4      if flag(dev)
tests/Text/URISpec.hs view
@@ -305,6 +305,11 @@         let uriWithoutSlash = "https://example.com"         uri <- URI.mkURI uriWithoutSlash         URI.render uri `shouldBe` uriWithoutSlash+    context "when the scheme is mailto" $+      it "does not escape @ in the path" $ do+        let mailtoUri = "mailto:john.smith@example.org"+        uri <- URI.mkURI mailtoUri+        URI.render uri `shouldBe` mailtoUri   describe "renderBs" $     it "sort of works" $       fmap URI.renderBs mkTestURI `shouldReturn` testURI