on master help sign in
Smarter isNumeric (. is not quoted)
commit3e3d9a3025ff7d80e8bd7c15a397c772933f1247 authorMichael Snoyman <michael@snoyman.com> dateSun 14 May 2017, 06:28 (9 years ago) parent3c727d4
4 files changed+15−4
ChangeLog.md+5 Data/Yaml/Internal.hs+4−3 test/Data/YamlSpec.hs+5 yaml.cabal+1−1
ChangeLog.md+5
@@ -1,3 +1,8 @@
1+## 0.8.22.1
2+
3+* Make numeric string detection slightly smarter so, e.g., `.` does
4+ not get quoted
5+
16## 0.8.22
27
38* Update to libyaml hosted on Github [#105](https://github.com/snoyberg/yaml/issues/105)
Data/Yaml/Internal.hs+4−3
@@ -284,10 +284,11 @@ specialStrings = HashSet.fromList $ T.words
284284 "y Y yes Yes YES n N no No NO true True TRUE false False FALSE on On ON off Off OFF null Null NULL ~"
285285
286286isNumeric :: Text -> Bool
287−isNumeric =
288− T.all isNumeric'
287+isNumeric t =
288+ T.all isNumeric' t && T.any isNumber t
289289 where
290− isNumeric' c = ('0' <= c && c <= '9')
290+ isNumber c = '0' <= c && c <= '9'
291+ isNumeric' c = isNumber c
291292 || c == 'e'
292293 || c == 'E'
293294 || c == '.'
test/Data/YamlSpec.hs+5
@@ -70,6 +70,7 @@ spec = do
7070 it "encode/decode strings" caseEncodeDecodeStrings
7171 it "decode invalid file" caseDecodeInvalid
7272 it "processes datatypes" caseDataTypes
73+ it "encode invalid numbers" caseEncodeInvalidNumbers
7374 describe "Data.Yaml.Pretty" $ do
7475 it "encode/decode" caseEncodeDecodeDataPretty
7576 it "encode/decode strings" caseEncodeDecodeStringsPretty
@@ -434,6 +435,10 @@ caseDataTypes =
434435 , ("null", D.Null)
435436 ]
436437
438+caseEncodeInvalidNumbers :: Assertion
439+caseEncodeInvalidNumbers =
440+ D.encode (D.String ".") @?= ".\n"
441+
437442caseDataTypesPretty :: Assertion
438443caseDataTypesPretty =
439444 D.decode (Pretty.encodePretty Pretty.defConfig val) @?= Just val
yaml.cabal+1−1
@@ -1,5 +1,5 @@
11name: yaml
2−version: 0.8.22
2+version: 0.8.22.1
33license: BSD3
44license-file: LICENSE
55author: Michael Snoyman <michael@snoyman.com>, Anton Ageev <antage@gmail.com>,Kirill Simonov