remaining dataenc to sandi conversions

I've tested all the dataenc to sandi conversions except Assistant.XMPP,
and all have unchanged behavior, including behavior on large unicode code
points.
This commit is contained in:
Joey Hess 2015-05-07 18:07:13 -04:00
parent 8ab56a5cf2
commit 4aba1c74bd
6 changed files with 15 additions and 9 deletions

View file

@ -22,7 +22,8 @@ import qualified Data.Map as M
import Data.ByteString (ByteString)
import qualified Data.ByteString as B
import Data.XML.Types
import qualified "dataenc" Codec.Binary.Base64 as B64
import qualified "sandi" Codec.Binary.Base64 as B64
import Data.Bits.Utils
{- Name of the git-annex tag, in our own XML namespace.
- (Not using a namespace URL to avoid unnecessary bloat.) -}
@ -212,10 +213,10 @@ encodeExitCode (ExitFailure n) = n
{- Base 64 encoding a ByteString to use as the content of a tag. -}
encodeTagContent :: ByteString -> [Node]
encodeTagContent b = [NodeContent $ ContentText $ T.pack $ B64.encode $ B.unpack b]
encodeTagContent b = [NodeContent $ ContentText $ T.pack $ w82s $ B.unpack $ B64.encode b]
decodeTagContent :: Element -> Maybe ByteString
decodeTagContent elt = B.pack <$> B64.decode s
decodeTagContent elt = either (const Nothing) Just (B64.decode $ B.pack $ s2w8 s)
where
s = T.unpack $ T.concat $ elementText elt

View file

@ -20,7 +20,8 @@ module Remote.Helper.Encryptable (
) where
import qualified Data.Map as M
import qualified "dataenc" Codec.Binary.Base64 as B64
import qualified "sandi" Codec.Binary.Base64 as B64
import qualified Data.ByteString as B
import Data.Bits.Utils
import Common.Annex
@ -172,12 +173,12 @@ describeEncryption c = case extractCipher c of
]
{- Not using Utility.Base64 because these "Strings" are really
- bags of bytes and that would convert to unicode and not roung-trip
- bags of bytes and that would convert to unicode and not round-trip
- cleanly. -}
toB64bs :: String -> String
toB64bs = B64.encode . s2w8
toB64bs = w82s . B.unpack . B64.encode . B.pack . s2w8
fromB64bs :: String -> String
fromB64bs s = fromMaybe bad $ w82s <$> B64.decode s
fromB64bs s = either (const bad) (w82s . B.unpack) (B64.decode $ B.pack $ s2w8 s)
where
bad = error "bad base64 encoded data"

2
debian/changelog vendored
View file

@ -40,6 +40,8 @@ git-annex (5.20150421) UNRELEASED; urgency=medium
honoring the setting of HOME. Instead, copy msysgit's ssh into PATH.
* Windows: Roll back to an older version of rsync from cygwin.
The newer version has some dependency on a newer ssh from cygwin.
* Switch from the obsolete dataenc library for base64 encoding to sandi.
(Thanks, Magnus Therning)
-- Joey Hess <id@joeyh.name> Tue, 21 Apr 2015 15:54:10 -0400

2
debian/control vendored
View file

@ -11,7 +11,7 @@ Build-Depends:
libghc-hslogger-dev,
libghc-pcre-light-dev,
libghc-cryptohash-dev (>= 0.11.0),
libghc-dataenc-dev,
libghc-sandi-dev,
libghc-utf8-string-dev,
libghc-aws-dev (>= 0.9.2-2~),
libghc-conduit-dev,

View file

@ -2,3 +2,5 @@
sandi is available in jessie, but not wheezy, so this is pending
EOL of wheezy support. --[[Joey]]
> [[fixed|done]] --[[Joey]]

View file

@ -54,7 +54,7 @@ constraints: Crypto ==4.2.5.1,
data-default-instances-containers ==0.0.1,
data-default-instances-dlist ==0.0.1,
data-default-instances-old-locale ==0.0.1,
dataenc ==0.14.0.7,
sandi ==0.3.0.1,
dbus ==0.10.8,
distributive ==0.4.4,
dlist ==0.7.0.1,