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

From: Lars-Dominik Braun <[email-masked]>
Date: Wed, 23 Apr 2025 16:08:52 +0200

* 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(+)

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" . "")

base-commit: b12d44dd5e35ac236bf3fbb5619b9c8c2f42c902
-- 
2.49.0