From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/32164 Path: main.gmane.org!not-for-mail From: Toby Speight Newsgroups: gmane.emacs.gnus.general Subject: `mm-quote-arg' and shell quoting in mailcap (was: Shouldn't...) Date: 14 Aug 2000 13:04:29 +0100 Organization: Citrix Systems Sender: owner-ding@hpc.uh.edu Message-ID: <87sns8oxpu.fsf_-_@delivery.cam.eu.citrix.com> References: <87n1moph1r.fsf@mharnois.workgroup.net> <87ya672i8q.fsf@mharnois.workgroup.net> <87bt30n4sf.fsf@mharnois.workgroup.net> <87hf8tc5hx.fsf@cachemir.echo-net.net> <87og303647.fsf@worldonline.dk> <2ng0ocmn6o.fsf@tiger.jia.vnet> <87vgx7pdao.fsf@worldonline.dk> <87r97vp9vr.fsf@worldonline.dk> NNTP-Posting-Host: coloc-standby.netfonds.no Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1035168479 18174 80.91.224.250 (21 Oct 2002 02:47:59 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 21 Oct 2002 02:47:59 +0000 (UTC) Return-Path: Original-Received: from spinoza.math.uh.edu (spinoza.math.uh.edu [129.7.128.18]) by mailhost.sclp.com (Postfix) with ESMTP id DCE3DD051E for ; Mon, 14 Aug 2000 08:07:38 -0400 (EDT) Original-Received: from sina.hpc.uh.edu (lists@Sina.HPC.UH.EDU [129.7.3.5]) by spinoza.math.uh.edu (8.9.1/8.9.1) with ESMTP id HAC13483; Mon, 14 Aug 2000 07:07:35 -0500 (CDT) Original-Received: by sina.hpc.uh.edu (TLB v0.09a (1.20 tibbs 1996/10/09 22:03:07)); Mon, 14 Aug 2000 07:04:34 -0500 (CDT) Original-Received: from mailhost.sclp.com (postfix@66-209.196.61.interliant.com [209.196.61.66] (may be forged)) by sina.hpc.uh.edu (8.9.3/8.9.3) with ESMTP id HAA18319 for ; Mon, 14 Aug 2000 07:04:23 -0500 (CDT) Original-Received: from hqvwall01.citrix.com (hqcon01.citrix.com [206.103.132.2]) by mailhost.sclp.com (Postfix) with SMTP id A4286D051E for ; Mon, 14 Aug 2000 08:04:47 -0400 (EDT) Original-Received: from 10.9.1.111 by hqvwall01.citrix.com (InterScan E-Mail VirusWall NT); Mon, 14 Aug 2000 08:04:43 -0400 (Eastern Daylight Time) Original-Received: by HQEXCHCON01 with Internet Mail Service (5.5.2650.21) id ; Mon, 14 Aug 2000 08:04:43 -0400 Original-Received: from delivery.cam.eu.citrix.com ([10.70.128.47]) by hwexch01.ctxuk.citrix.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2650.21) id QLGAJBTR; Mon, 14 Aug 2000 13:04:30 +0100 Original-To: The Gnus Mailing List Original-Lines: 52 User-Agent: Gnus/5.0803 (Gnus v5.8.3) Emacs/20.7 X-Face: wqk-$Z5Z In article <87r97vp9vr.fsf@worldonline.dk>, 0> Rene H. Larsen ("Rene") wrote: Rene> The workaround I use right now is to modify mm-quote-arg to only Rene> quote single quotes (using the mildly hideous '"'"' hack). This Rene> is what I've put in my .gnus.el: Rene> Rene> ,---- Rene> | ;;; Convince Gnus to handle single-quoted mailcap entries correctly. Rene> | (eval-after-load 'mm-util Rene> | (defun mm-quote-arg (arg) Rene> | "Return a version of ARG that is safe to evaluate in a shell." Rene> | (let ((pos 0) new-pos accum) Rene> | ;; *** bug: we don't handle newline characters properly Rene> | (while (setq new-pos (string-match "'" arg pos)) Rene> | (push (substring arg pos new-pos) accum) Rene> | (push "'\"'\"" accum) Rene> | (push (list (aref arg new-pos)) accum) Rene> | (setq pos (1+ new-pos))) Rene> | (if (= pos 0) Rene> | arg Rene> | (apply 'concat (nconc (nreverse accum) (list (substring arg pos)))))))) Rene> `---- I use ordinary \' like this dot-gnus.el> (eval-after-load "mm-util" (quote dot-gnus.el> (defun mm-quote-arg (arg) dot-gnus.el> "Return a version of ARG that is safe to evaluate in a shell." dot-gnus.el> (let ((pos 0) new-pos accum) dot-gnus.el> (while (setq new-pos (string-match "'" arg pos)) dot-gnus.el> (push (substring arg pos new-pos) accum) dot-gnus.el> (push "\\" accum) dot-gnus.el> (push (list (aref arg new-pos)) accum) dot-gnus.el> (setq pos (1+ new-pos))) dot-gnus.el> (if (= pos 0) dot-gnus.el> arg dot-gnus.el> (apply 'concat (nconc (nreverse accum) (list (substring arg pos))))))))) WIBNI if this kind of definition was automatically selected on Debian systems? (or if the filenames were always translated to something innocuous? That's the Right Thing IMO) Rene> To handle double quoted entries you'll need something a bit Rene> different (more like what is used for the non-quoted case). If Rene> your mailcap entries are inconsistently quoted, you're basically Rene> screwed :/. With a SMOP, `mm-quote-arg' could parse the command up to the %s and determine how to quote the filename. I'll leave it as an exercise to the reader.