From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jason Rumney Newsgroups: gmane.emacs.devel Subject: Re: C file recoginzed as image file Date: Sun, 07 Jan 2007 11:49:21 +0000 Message-ID: <45A0DE41.9080603@gnu.org> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1168170591 23340 80.91.229.12 (7 Jan 2007 11:49:51 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 7 Jan 2007 11:49:51 +0000 (UTC) Cc: Chris Moore , c.a.rendle@gmail.com, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jan 07 12:49:48 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1H3WX5-0000qo-Ud for ged-emacs-devel@m.gmane.org; Sun, 07 Jan 2007 12:49:48 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1H3WX5-0004ZI-Ho for ged-emacs-devel@m.gmane.org; Sun, 07 Jan 2007 06:49:47 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1H3WWs-0004Yb-1D for emacs-devel@gnu.org; Sun, 07 Jan 2007 06:49:34 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1H3WWq-0004Xr-Br for emacs-devel@gnu.org; Sun, 07 Jan 2007 06:49:33 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1H3WWq-0004Xo-7B for emacs-devel@gnu.org; Sun, 07 Jan 2007 06:49:32 -0500 Original-Received: from [194.106.33.237] (helo=outmail1.freedom2surf.net) by monty-python.gnu.org with esmtp (Exim 4.52) id 1H3WWn-0004Xv-9c; Sun, 07 Jan 2007 06:49:29 -0500 Original-Received: from [127.0.0.1] (i-83-67-23-108.freedom2surf.net [83.67.23.108]) by outmail1.freedom2surf.net (Postfix) with ESMTP id 1F7A15114D; Sun, 7 Jan 2007 11:49:28 +0000 (GMT) User-Agent: Thunderbird 1.5.0.9 (Windows/20061207) Original-To: rms@gnu.org In-Reply-To: X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:64909 Archived-At: Richard Stallman wrote: > > Besides which, a jpg file starts with characters that don't make any > > sense at the start of a C file. So if it looks like a plausible C > > file, it won't be treated as a jpeg. > > If it looks like a plausible C file to who? > > To anyone who knows C. The first two characters of a JPG file are > character codes above 128, that would obviously be invalid in C. > The user cannot see those first two characters until they load the file. If it is in fact a dangerous jpg file, they will not find out until too late. If my patch to use image-mode-maybe for magic-mode-alist is installed, this will not happen for file extensions that the user might reasonably expect to be something other than an image. But it will still happen for unknown file extensions, which in some cases (.thm files, or thumbnails without an extension) will be considered a good thing, but there may also be cases where a user receives a file with an unknown extension and opens it in Emacs to see the file contents to decide what type of file it is, expecting Emacs to be a safe way of checking such files. So maybe it would be better to define a new function `image-mode-confirm' which always asks the user before using image-mode on a file, and using that for magic-mode-alist and other uses which could be considered risky.