emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#54846: closed ([PATCH] gnu: linux: Escape the values of string-type


From: GNU bug Tracking System
Subject: bug#54846: closed ([PATCH] gnu: linux: Escape the values of string-type kconfig options)
Date: Tue, 17 May 2022 15:55:02 +0000

Your message dated Tue, 17 May 2022 15:54:00 +0000 (UTC)
with message-id <0407c0d7-f102-4281-9e02-595da2bb6f59@gmail.com>
and subject line Re: bug#54846: [PATCH] gnu: linux: Escape the values of 
string-type kconfig options
has caused the debbugs.gnu.org bug report #54846,
regarding [PATCH] gnu: linux: Escape the values of string-type kconfig options
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs@gnu.org.)


-- 
54846: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=54846
GNU Bug Tracking System
Contact help-debbugs@gnu.org with problems
--- Begin Message --- Subject: [PATCH] gnu: linux: Escape the values of string-type kconfig options Date: Sun, 10 Apr 2022 19:24:10 -0700
 * gnu/packages/linux.scm (config->string): add escape-string

Handles characters within the set
(char-set-intersection char-set:ascii char-set:printing), removing
those which are known to be unsupported.
---
 gnu/packages/linux.scm | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index b31fe0a580..60ae668fd9 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -761,6 +761,22 @@ (define %bpf-extra-linux-options
     ("CONFIG_IKHEADERS" . #t)))
 
 (define (config->string options)
+  (define (escape-string str)
+    "Returns STR with the escapes necessary to be read as a string-type
+    option's value. Handles characters within the set (char-set-intersection
+    char-set:ascii char-set:printing), removing those which are known to be
+    unsupported."
+    (fold (match-lambda* (((match? fmt) str)
+                         (transform-string str match?
+                                           (cut format #f fmt <>))))
+         str
+         `((#\# "") ; No known way to escape # characters.
+           (#\$ "$~a")
+           ("\"\\'`" "\\~a")
+           (";:()#" "\\\\~a")
+           ("|" "\\\\\\~a")
+           ;; No support for tabs, newlines, etc.
+           (,(char-set->string (ucs-range->char-set 9 14)) ""))))
   (string-join (map (match-lambda
                       ((option . 'm)
                        (string-append option "=m"))
@@ -769,7 +785,9 @@ (define (config->string options)
                       ((option . #f)
                        (string-append option "=n"))
                       ((option . string)
-                       (string-append option "=\"" string "\"")))
+                       (string-append option "=\""
+                                     (escape-string string)
+                                     "\"")))
                     options)
                "\n"))
 
-- 
2.34.0




--- End Message ---
--- Begin Message --- Subject: Re: bug#54846: [PATCH] gnu: linux: Escape the values of string-type kconfig options Date: Tue, 17 May 2022 15:54:00 +0000 (UTC)
[won't-fix]


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]