[bug#78013] guix: toml: Add missing escape pattern.

Message ID 36f5a72646c66b618e3625c7d2b8706fe36174cd.1745417268.git.lars@6xq.net
State New
Headers
Series [bug#78013] guix: toml: Add missing escape pattern. |

Commit Message

Lars-Dominik Braun April 23, 2025, 2:08 p.m. UTC
  * guix/build/toml.scm (eval-toml-file): Add missing mappings.
* tests/toml.scm ("parse-toml: String escapes"): Test all escapes from
the specification.

Change-Id: I135f6eebd8c7903eb6ebac1120c0ef071779f4ec
---
 guix/build/toml.scm | 2 ++
 tests/toml.scm      | 4 ++++
 2 files changed, 6 insertions(+)


base-commit: b12d44dd5e35ac236bf3fbb5619b9c8c2f42c902
  

Patch

diff --git a/guix/build/toml.scm b/guix/build/toml.scm
index a9be0887e7..7d8b7ed834 100644
--- a/guix/build/toml.scm
+++ b/guix/build/toml.scm
@@ -402,6 +402,8 @@  (define (eval-toml-file parse-tree)
                     (('escaped "b") "\b")
                     (('escaped "t") "\t")
                     (('escaped "n") "\n")
+                    (('escaped "f") "\f")
+                    (('escaped "r") "\r")
                     (('escaped (? (lambda (x) (>= (string-length x) 4)) u))
                      (list->string (list (integer->char (string->number u 16)))))
                     ((? string? s) s))
diff --git a/tests/toml.scm b/tests/toml.scm
index 64bc667f0c..083fafa526 100644
--- a/tests/toml.scm
+++ b/tests/toml.scm
@@ -97,6 +97,10 @@  (define-module (test-toml)
   '(("str" . "I'm a string. \"You can quote me\". Name\tJos\u00E9\nLocation\tSF."))
   (parse-toml "str = \"I'm a string. \\\"You can quote me\\\". Name\\tJos\\u00E9\\nLocation\\tSF.\""))
 
+(test-equal "parse-toml: String escapes"
+  '(("str" . "\b\t\n\f\r\"\\"))
+  (parse-toml "str = \"\\b\\t\\n\\f\\r\\\"\\\\\""))
+
 (test-equal "parse-toml: Empty string"
   '(("str1" . "")
     ("str2" . "")