From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id qAKCKMjxVWLHFwEAgWs5BA (envelope-from ) for ; Tue, 12 Apr 2022 23:40:24 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id CBTrIMjxVWL83AAAG6o9tA (envelope-from ) for ; Tue, 12 Apr 2022 23:40:24 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id C909534615 for ; Tue, 12 Apr 2022 23:40:23 +0200 (CEST) Received: from localhost ([::1]:43096 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1neOFK-0004Xz-W2 for larch@yhetil.org; Tue, 12 Apr 2022 17:40:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57410) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1neOF1-0004Xm-2F for guix-patches@gnu.org; Tue, 12 Apr 2022 17:40:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:56451) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1neOF0-00028g-PD for guix-patches@gnu.org; Tue, 12 Apr 2022 17:40:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1neOF0-0003QX-Lj for guix-patches@gnu.org; Tue, 12 Apr 2022 17:40:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#54846] [PATCH] gnu: linux: Escape the values of string-type kconfig options Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 12 Apr 2022 21:40:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54846 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: antlers Cc: 54846@debbugs.gnu.org Received: via spool by 54846-submit@debbugs.gnu.org id=B54846.164979955813107 (code B ref 54846); Tue, 12 Apr 2022 21:40:02 +0000 Received: (at 54846) by debbugs.gnu.org; 12 Apr 2022 21:39:18 +0000 Received: from localhost ([127.0.0.1]:50348 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1neOEH-0003PL-Sa for submit@debbugs.gnu.org; Tue, 12 Apr 2022 17:39:18 -0400 Received: from eggs.gnu.org ([209.51.188.92]:35712) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1neOEG-0003P6-FA for 54846@debbugs.gnu.org; Tue, 12 Apr 2022 17:39:16 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:49600) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1neOEB-00023X-2x; Tue, 12 Apr 2022 17:39:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=SJVm8eJXKkeRpxuNEPduL1sOOzWMIHHQMunHt+fs95A=; b=IcKbDIAx9uA6XUIdgMvU 1SXpvGEs+eIGqzm5Wg9lDlHbfCMZ9i2IB3KOnB8sHzkDSuvD1xHaZrqxI9FWR/zY5aAMxBDgAqH9z rDLSWWN0QD6oG0AVAsVENlqt/clzBZe7m/LQ+NeHZ2v78uVCUPa7dm4ePgY7ezNnp2KUaaE/ShQP3 VqAca/G/GRULKi4WcW4ExAgw/STDmJTuMwIR5HVl88NaP4yTe22H4KO3pCWnpvSGbjLZRYRk1AtNW MAjhXFPiRPvkOjDstxfmFFBxAOzJpIRIWyEwOo11iUBpJdK+toKYo1swxGCG9/sePJKl/ZKk0lF3R fQIWzt8Hq/jafw==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201]:64291 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1neOEA-0003qH-Mb; Tue, 12 Apr 2022 17:39:10 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20220411022410.5606-1-autumnalantlers@gmail.com> Date: Tue, 12 Apr 2022 23:39:07 +0200 In-Reply-To: <20220411022410.5606-1-autumnalantlers@gmail.com> (antlers's message of "Sun, 10 Apr 2022 19:24:10 -0700") Message-ID: <8735iic77o.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1649799624; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=SJVm8eJXKkeRpxuNEPduL1sOOzWMIHHQMunHt+fs95A=; b=md2IfKH32FAPBS+H2F4tJtinr7S87qcxC3jGOlTXCtAUMKFeoGxvlqJBRQ5S92I1OaxXYB 03MzlVIxGETdM9/LR9UNCXpz4a1L1IqvBgj67MPN42D0oIp5qhuMeAKrkDnbKtFiydFaC7 6QtgSl2sacL3VntYeNYEoESfSG4SpWlFEPOAt7D6m9tKBUpRzpN0S+ONoNZYs+FX70nEUD NOw8sgTiz2gWcMfI2O1MvREfk+lUFitFX8941OimtWdfWzk5e1dsIfX1gllcleot/zt9ze aejkvdW9s0twr2ifIcIj6A4uGMNTnFjoqeREUy8fKzwuz47Bnf07qArA8GWivA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1649799624; a=rsa-sha256; cv=none; b=rYLIPVrBHhAZZPqxdewijRXZ3LzgV8FXB+WtHIuzh0r4IXm0kCrhAlHBU1Nf1bhJAv+HlX 2ONwzat67sF90dnYKX5irVmwAQ5yYhl5uSZqf7h+/yPRRBvEPN1GlY05b5SyxYnYSkmoaO wu18GQV6EKLGC4ane0ZSubYVnLYfuyYBVq9HP3GBudAHN07CXleRnV0cAFg6VVWkU2VgDj gVDD54qslRGOyBQe/PUH4Hupe8lOniHlqMlOhjlQHQtXISuJYteQSya4+XvtzGMEtOhCbb Qmz1ozqI3NhaMPfUbG4r+ijpmTnRdSQV2c5a1nhsmFzp0SuN/fIh6REcQDyG7A== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=IcKbDIAx; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -5.06 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=IcKbDIAx; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: C909534615 X-Spam-Score: -5.06 X-Migadu-Scanner: scn0.migadu.com X-TUID: bLn21kAZWFzR Hi, antlers skribis: > * 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. [...] > (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-intersec= tion > + char-set:ascii char-set:printing), removing those which are known to= be > + unsupported." Nitpick: You can turn the docstring into a comment since the docstring wouldn=E2=80=99t be accessible anyway. > + (fold (match-lambda* (((match? fmt) str) > + (transform-string str match? > + (cut format #f fmt <>)))) Please avoid tabs. =E2=80=98transform-string=E2=80=99 is from (texinfo string-utils), which is= not imported here. IMO, we=E2=80=99d rather avoid depending on this module since it=E2= =80=99s really designed for the Texinfo machinery. > + 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)) "")))) I wonder if this should be implemented in terms of =E2=80=98string-fold=E2= =80=99 instead: (string-concatenate-reverse (string-fold (lambda (chr result) (match chr (#\# (cons "" result)) ;; =E2=80=A6 (_ (cons (string chr) result)))) '() str)) Thoughts? Thanks, Ludo=E2=80=99.