From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuri Khan Newsgroups: gmane.emacs.help Subject: Re: Printf and quoting in general, SQL injection in particular Date: Sat, 26 Jun 2021 14:30:59 +0700 Message-ID: References: <87pmwgdiyj.fsf@zoho.eu> <83y2b3tq07.fsf@gnu.org> <871r8vcrnm.fsf@posteo.net> <20210621141148.GA29347@tuxteam.de> <87zgvjcgh6.fsf@zoho.eu> <87h7hqviu4.fsf@zoho.eu> <87eecp2k6l.fsf@zoho.eu> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25927"; mail-complaints-to="usenet@ciao.gmane.io" To: Emanuel Berg , help-gnu-emacs Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jun 26 09:31:37 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lx2mu-0006ah-St for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 26 Jun 2021 09:31:36 +0200 Original-Received: from localhost ([::1]:40770 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lx2mt-0008E7-VV for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 26 Jun 2021 03:31:35 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56548) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lx2mY-0008Cs-CL for help-gnu-emacs@gnu.org; Sat, 26 Jun 2021 03:31:14 -0400 Original-Received: from mail-ua1-x92a.google.com ([2607:f8b0:4864:20::92a]:46923) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lx2mW-00017V-EL for help-gnu-emacs@gnu.org; Sat, 26 Jun 2021 03:31:14 -0400 Original-Received: by mail-ua1-x92a.google.com with SMTP id x37so61848uac.13 for ; Sat, 26 Jun 2021 00:31:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :content-transfer-encoding; bh=kKNwIfS+UCAN0adAIVKdE7w31SSn1T5T11ODGoQhFqo=; b=NtsE9KOD+AtVTrRg809Q0NaVEjrSZ0kxd8ROp0Agsntv1vnrq7L0XkwN9+skQWMZxn goITbv+1nJyNbHzBMj1zWJmpSHOz+wp0nkUylepEqX8wEn6ToD6Fnw53X+NYt4n6GfzD wdfDtaWVzIzE/sOZKssOslNruKgdmgFArT9VWi+ZOEQ+GTTjvhI4ZjMQC9YwNR6uAIT0 As7FslQSafOvZReLF/nkUrWsNHQML5m6sx33yj4GNJee6WOElEN4JiSBnVKhpy+Uk1pN C+aScPGEhrolVi1hJ18TaO/kQhspPbXgx2Pj+p6gCO9xrF8+QZ4C436rnJwvaQona+q1 uRfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:content-transfer-encoding; bh=kKNwIfS+UCAN0adAIVKdE7w31SSn1T5T11ODGoQhFqo=; b=lPPsYYo+Aob5zkKV5Cue7KoOinE5nqkbe4r7O5UADWG57EBwfRd1ngM4bUw2Th0sSV 8OFJ/nMzgbDmc69vIRz7GlleY6+z5U2MUyRXzl3xEeB8RpOnG45nwm9616Z/qCQljztE mJ6RL2QmlqgoY6kZt8qfMUqX/ntDArx7hFw9/766y0u/kfRo3yHZPYu+LoalsQEhSaIK j6Dg7lNnwDYGUPUoM3xbPjghMg1Nc0gpC5IYCofF38fdlt81uRY90C9pDwa7YDSIHXra OwgQvxYNf/uRkWDlQS1Mvf49haSbO17CQlvWcM7/5BcHsZ8yvHAblgw1yiq5D3u7cf8G lYFA== X-Gm-Message-State: AOAM532gc1hqkVCIM8neEZ+PeAJ66WzVu9SXm9Ix7maHpEh108vr6kBq B6HPqtAjGW/6kysXpVhou/n/IxymsY/uq95dbRo= X-Google-Smtp-Source: ABdhPJzEXLfxc0rf5l19++khFWoOc1VCpkVW97rLvuKiacdjkPBd8bc8AL8ZYQN6tJexqq5sbx5OQr901emOske2Tz4= X-Received: by 2002:ab0:4128:: with SMTP id j37mr14677470uad.79.1624692670567; Sat, 26 Jun 2021 00:31:10 -0700 (PDT) In-Reply-To: <87eecp2k6l.fsf@zoho.eu> Received-SPF: pass client-ip=2607:f8b0:4864:20::92a; envelope-from=yurivkhan@gmail.com; helo=mail-ua1-x92a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:131247 Archived-At: On Sat, 26 Jun 2021 at 13:56, Emanuel Berg via Users list for the GNU Emacs text editor wrote: > Relax, this notion that you shouldn't construct file paths by > string functions, nor SQL queries for that matter, and what > more? hyperlinks? Hyperlinks, too. One of the requirements of URLs is that all non-ascii and some ascii characters be %-encoded when used in the path or query string, or punycode-encoded when used in the host name: (let ((base "http://ru.wikipedia.org/wiki/") (term "=D0=93=D0=B8=D0=BF=D0=B5=D1=80=D1=81=D1=81=D1=8B=D0=BB=D0= =BA=D0=B0") (joined (concat base term))) (assert (string=3D joined "https://ru.wikipedia.org/wiki/%D0%93%D0%B8%D0%BF%D0%B5%D1%80%D1%81%D1%81%D= 1%8B%D0%BB%D0%BA%D0%B0"))) ;; alas, no Another rule is that resolving a relative reference containing a path against a base URL will drop the last segment of the base: (let ((base "http://example.org/foo") (href "bar") (resolved (concat base href))) (assert (string=3D resolved "http://example.org/bar"))) ;; also no String concat does not know any of these rules. It is okay to represent file names, SQL queries, and URLs as strings *internally*. It is okay to use string functions to implement high-level domain-specific functions. In many cases, interoperating with external code will also require these things represented as strings. But it is a good idea to use domain-specific functions to manipulate file names, queries, and URLs, rather than string functions, because this way you are less likely to violate those types=E2=80=99 invariants.