Do not parse string environment variables into numbers/booleans #1061
This commit is contained in:
parent
1567145110
commit
e06a8109d0
@ -1,3 +1,7 @@
|
|||||||
|
## 1.4.2
|
||||||
|
|
||||||
|
* Do not parse string environment variables into numbers/booleans [#1061](https://github.com/yesodweb/yesod/issues/1061)
|
||||||
|
|
||||||
## 1.4.1
|
## 1.4.1
|
||||||
|
|
||||||
Provide the `Yesod.Default.Config2` module, for use by newer scaffoldings.
|
Provide the `Yesod.Default.Config2` module, for use by newer scaffoldings.
|
||||||
|
|||||||
@ -69,11 +69,23 @@ applyEnvValue requireEnv' env =
|
|||||||
goV (String t1) = fromMaybe (String t1) $ do
|
goV (String t1) = fromMaybe (String t1) $ do
|
||||||
t2 <- T.stripPrefix "_env:" t1
|
t2 <- T.stripPrefix "_env:" t1
|
||||||
let (name, t3) = T.break (== ':') t2
|
let (name, t3) = T.break (== ':') t2
|
||||||
|
mdef = fmap parseValue $ T.stripPrefix ":" t3
|
||||||
Just $ case H.lookup name env of
|
Just $ case H.lookup name env of
|
||||||
Just val -> parseValue val
|
Just val ->
|
||||||
|
-- If the default value parses as a String, we treat the
|
||||||
|
-- environment variable as a raw value and do not parse it.
|
||||||
|
-- This means that things like numeric passwords just work.
|
||||||
|
-- However, for originally numerical or boolean values (e.g.,
|
||||||
|
-- port numbers), we still perform a normal YAML parse.
|
||||||
|
--
|
||||||
|
-- For details, see:
|
||||||
|
-- https://github.com/yesodweb/yesod/issues/1061
|
||||||
|
case mdef of
|
||||||
|
Just (String _) -> String val
|
||||||
|
_ -> parseValue val
|
||||||
Nothing ->
|
Nothing ->
|
||||||
case T.stripPrefix ":" t3 of
|
case mdef of
|
||||||
Just val | not requireEnv' -> parseValue val
|
Just val | not requireEnv' -> val
|
||||||
_ -> Null
|
_ -> Null
|
||||||
goV v = v
|
goV v = v
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
name: yesod
|
name: yesod
|
||||||
version: 1.4.1.5
|
version: 1.4.2
|
||||||
license: MIT
|
license: MIT
|
||||||
license-file: LICENSE
|
license-file: LICENSE
|
||||||
author: Michael Snoyman <michael@snoyman.com>
|
author: Michael Snoyman <michael@snoyman.com>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user