From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: James Cloos Newsgroups: gmane.emacs.devel,gmane.emacs.pretest.bugs Subject: Re: unable to open jpg file Date: Mon, 14 Jan 2008 22:36:38 +0000 Message-ID: References: <61562314-8495-4E17-A6BE-C2F73B85155B@xahlee.org> <372F90F5-325B-46D5-99ED-BB315E37EF0C@xahlee.org> <478B618B.6040404@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1200373094 29414 80.91.229.12 (15 Jan 2008 04:58:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 15 Jan 2008 04:58:14 +0000 (UTC) Cc: xah lee , YAMAMOTO Mitsuharu , Jason Rumney To: emacs-pretest-bug@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jan 15 05:58:37 2008 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 1JEdsi-0007Ce-Qp for ged-emacs-devel@m.gmane.org; Tue, 15 Jan 2008 05:58:37 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JEdsK-0007zp-Gj for ged-emacs-devel@m.gmane.org; Mon, 14 Jan 2008 23:58:12 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JEdsG-0007zk-Vt for emacs-devel@gnu.org; Mon, 14 Jan 2008 23:58:09 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JEdsD-0007yw-J1 for emacs-devel@gnu.org; Mon, 14 Jan 2008 23:58:07 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JEdsD-0007yt-C0 for emacs-devel@gnu.org; Mon, 14 Jan 2008 23:58:05 -0500 Original-Received: from fencepost.gnu.org ([140.186.70.10]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JEdsD-0000ZJ-7s for emacs-devel@gnu.org; Mon, 14 Jan 2008 23:58:05 -0500 Original-Received: from mx10.gnu.org ([199.232.76.166]) by fencepost.gnu.org with esmtp (Exim 4.67) (envelope-from ) id 1JEdsC-0001y2-Ng for emacs-pretest-bug@gnu.org; Mon, 14 Jan 2008 23:58:04 -0500 Original-Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1JEds9-0000Yr-OC for emacs-pretest-bug@gnu.org; Mon, 14 Jan 2008 23:58:04 -0500 Original-Received: from eagle.jhcloos.com ([207.210.242.212]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JEds9-0000YZ-Dt; Mon, 14 Jan 2008 23:58:01 -0500 Original-Received: by eagle.jhcloos.com (Postfix, from userid 10) id B473D40175; Tue, 15 Jan 2008 04:57:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jhcloos.com; s=eagle; t=1200373077; bh=VUGroo0ulndQE41b3ZPecIhuRrrQtvj5Xl2n6jQr1 NU=; h=From:To:Cc:Subject:In-Reply-To:References:User-Agent:Face: Copyright:OpenPGP:OpenPGP-Fingerprint:X-Hashcash:X-Hashcash: X-Hashcash:X-Hashcash:Date:Message-ID:Lines:MIME-Version: Content-Type; b=zBel/UluCoxxlDEX1hqXT34Mn1mwhcfgS0SrgThIXDA0jHYu31 boJr8C+FDz6koUYWthWbJE7eeBH1h2H4vb+NVoqURfFFMJSHAil+L8vLJ1dtFkOZTSZ gN1SPKTHPN0JmLNNQataIFSThw6cIe1LqY6oJu9bpRUBurPbPXbxNw= Original-Received: by lugabout.jhcloos.org (Postfix, from userid 500) id 6E104214F22; Mon, 14 Jan 2008 22:36:38 +0000 (UTC) In-Reply-To: <478B618B.6040404@gnu.org> (Jason Rumney's message of "Mon, 14 Jan 2008 13:20:11 +0000") User-Agent: Gnus/5.110007 (No Gnus v0.7) Emacs/23.0.60 (gnu/linux) Face: iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAI1J REFUOE+lU9ESgCAIg64P1y+ngUdxhl5H8wFbbM0OmUiEhKkCYaZThXCo6KE5sCbA1DDX3genvO4d eBQgEMaM5qy6uWk4SfBYfdu9jvBN9nSVDOKRtwb+I3epboOsOX5pZbJNsBJFvmQQ05YMfieIBnYX FK2N6dOawd97r/e8RjkTLzmMsiVgrAoEugtviCM3v2WzjgAAAABJRU5ErkJggg== Copyright: Copyright 2007 James Cloos OpenPGP: ED7DAEA6; url=http://jhcloos.com/public_key/0xED7DAEA6.asc OpenPGP-Fingerprint: E9E9 F828 61A4 6EA9 0F2B 63E7 997A 9F17 ED7D AEA6 X-Hashcash: 1:23:080114:jasonr@gnu.org::96kkuqw9ihnI5bD2:00008vL X-Hashcash: 1:23:080114:xah@xahlee.org::uMT/d0fZj5hvXfQ6:000BOyx X-Hashcash: 1:23:080114:mituharu@math.s.chiba-u.ac.jp::itJ4WaprsWnlZ+QN:00000000000000000000000000000000O4fb X-Hashcash: 1:23:080114:emacs-pretest-bug@gnu.org::/aOw6DXmwkhrW89J:000000000000000000000000000000000000Wort Original-Lines: 29 X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 2) X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) 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:86927 gmane.emacs.pretest.bugs:20655 Archived-At: File(1)'s magic file says this, for detecting jpegs: ,----[ excerpt from /usr/share/misc/file/magic ] | # JPEG images | # SunOS 5.5.1 had | # | # 0 string \377\330\377\340 JPEG file | # 0 string \377\330\377\356 JPG file | # | # both of which turn into "JPEG image data" here. | # | 0 beshort 0xffd8 JPEG image data | >6 string JFIF \b, JFIF standard `---- So rather than searching for JFIF or EXIF emacs should test the first two or four octets for the real magic cookie. Magic.mime(4), used to determine the MIME type of a file, also only tests the first two octets for 0xff and 0xd8. It should be enough, then, for Emacs to test only those two octets as well. Incidently, file(1) is under a 2-clause BSD-style license; incorporating the magic.mime file and using that to determine how to open files might make for a more robust -- or at least well-tested -- system. -JimC -- James Cloos OpenPGP: 1024D/ED7DAEA6