unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Unicode handling breaks Jpeg image detection?
@ 2008-06-24 20:23 Chong Yidong
  2008-06-25  2:48 ` Kenichi Handa
  0 siblings, 1 reply; 5+ messages in thread
From: Chong Yidong @ 2008-06-24 20:23 UTC (permalink / raw)
  To: emacs-devel

In Emacs 23, jpeg content autodetection seems to be broken.  I think
this may be an encoding issue.  To see this, rename any jpeg image from
foo.jpg to foo.JPG (to turn off file-name detection), and open it in
Emacs.  Emacs 23 fails to detect the image, while Emacs 22 works.

In a buffer containing the exact same jpeg data, do

  M-: (string-match "\\`\xff\xd8" (buffer-string)) RET

This gives 0 in Emacs 22, and nil in Emacs 23.  This is the check that
makes image-type-header-regexps and image-jpeg-p fail for Emacs 23.

Could someone try to fix this?




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Unicode handling breaks Jpeg image detection?
  2008-06-24 20:23 Unicode handling breaks Jpeg image detection? Chong Yidong
@ 2008-06-25  2:48 ` Kenichi Handa
  2008-06-25 12:37   ` Stephen Berman
  0 siblings, 1 reply; 5+ messages in thread
From: Kenichi Handa @ 2008-06-25  2:48 UTC (permalink / raw)
  To: Chong Yidong; +Cc: emacs-devel

In article <87od5qbn0b.fsf@stupidchicken.com>, Chong Yidong <cyd@stupidchicken.com> writes:

> In Emacs 23, jpeg content autodetection seems to be broken.  I think
> this may be an encoding issue.  To see this, rename any jpeg image from
> foo.jpg to foo.JPG (to turn off file-name detection), and open it in
> Emacs.  Emacs 23 fails to detect the image, while Emacs 22 works.

> In a buffer containing the exact same jpeg data, do

>   M-: (string-match "\\`\xff\xd8" (buffer-string)) RET

> This gives 0 in Emacs 22, and nil in Emacs 23.  This is the check that
> makes image-type-header-regexps and image-jpeg-p fail for Emacs 23.

I've just installed a fix.

---
Kenichi Handa
handa@ni.aist.go.jp




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Unicode handling breaks Jpeg image detection?
  2008-06-25  2:48 ` Kenichi Handa
@ 2008-06-25 12:37   ` Stephen Berman
  2008-07-04  7:20     ` Kenichi Handa
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Berman @ 2008-06-25 12:37 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1048 bytes --]

On Wed, 25 Jun 2008 11:48:34 +0900 Kenichi Handa <handa@m17n.org> wrote:

> In article <87od5qbn0b.fsf@stupidchicken.com>, Chong Yidong <cyd@stupidchicken.com> writes:
>
>> In Emacs 23, jpeg content autodetection seems to be broken.  I think
>> this may be an encoding issue.  To see this, rename any jpeg image from
>> foo.jpg to foo.JPG (to turn off file-name detection), and open it in
>> Emacs.  Emacs 23 fails to detect the image, while Emacs 22 works.
>
>> In a buffer containing the exact same jpeg data, do
>
>>   M-: (string-match "\\`\xff\xd8" (buffer-string)) RET
>
>> This gives 0 in Emacs 22, and nil in Emacs 23.  This is the check that
>> makes image-type-header-regexps and image-jpeg-p fail for Emacs 23.
>
> I've just installed a fix.

This fix results in a file mode specification error.  To reproduce:
1. C-x C-f /tmp/test
2. Type the letter "ä" (a-umlaut).
3. C-x C-s
4. C-x k RET
5. C-x C-f /tmp/test
==> File mode specification error: (error "Can't convert the 0th
character to unibyte")

Backtrace attached.

Steve Berman


[-- Attachment #2: backtrace --]
[-- Type: text/plain, Size: 3862 bytes --]

Debugger entered--Lisp error: (error "Can't convert the 0th character to unibyte")
  string-to-unibyte("\x00e4")
  (setq data (string-to-unibyte data))
  image-jpeg-p("\x00e4")
  funcall(image-jpeg-p "\x00e4")
  (and (consp image-type) (funcall (car image-type) (or data ...)) (setq image-type (cdr image-type)))
  (or (and (symbolp image-type) (looking-at regexp)) (and (consp image-type) (funcall ... ...) (setq image-type ...)))
  (if (or (and ... ...) (and ... ... ...)) (setq type image-type types nil) (setq types (cdr types)))
  (let ((regexp ...) (image-type ...) data) (if (or ... ...) (setq type image-type types nil) (setq types ...)))
  (while types (let (... ... data) (if ... ... ...)))
  (let ((types image-type-header-regexps) type (opoint ...)) (goto-char (point-min)) (while types (let ... ...)) (goto-char opoint) type)
  image-type-from-buffer()
  (let* ((type ...) (auto ...)) (and auto (or ... ...)))
  image-type-auto-detected-p()
  funcall(image-type-auto-detected-p)
  (if (functionp re) (funcall re) (looking-at re))
  (lambda (re dummy) (if (functionp re) (funcall re) (looking-at re)))(image-type-auto-detected-p nil)
  assoc-default(nil ((image-type-auto-detected-p . image-mode) ("\\(?:<\\?xml[ 	
\n]+[^>]*>\\)?[ 	
\n]*<\\(?:!--\\(?:[^-]\\|-[^-]\\)*-->[ 	
\n]*<\\)*\\(?:!DOCTYPE[ 	
\n]+[^>]*>[ 	
\n]*<[ 	
\n]*\\(?:!--\\(?:[^-]\\|-[^-]\\)*-->[ 	
\n]*<\\)*\\)?[Hh][Tt][Mm][Ll]" . html-mode) ("<!DOCTYPE[ 	
\n]+[Hh][Tt][Mm][Ll]" . html-mode) ("<\\?xml " . xml-mode) ("[ 	
\n]*<\\(?:!--\\(?:[^-]\\|-[^-]\\)*-->[ 	
\n]*<\\)*!DOCTYPE " . sgml-mode) ("%!PS" . ps-mode) ("# xmcd " . conf-unix-mode)) (lambda (re dummy) (if (functionp re) (funcall re) (looking-at re))))
  (save-restriction (narrow-to-region (point-min) (min ... ...)) (assoc-default nil magic-fallback-mode-alist (lambda ... ...)))
  (save-excursion (goto-char (point-min)) (save-restriction (narrow-to-region ... ...) (assoc-default nil magic-fallback-mode-alist ...)))
  (setq done (save-excursion (goto-char ...) (save-restriction ... ...)))
  (if (setq done (save-excursion ... ...)) (set-auto-mode-0 done keep-mode-if-same))
  (if done nil (if (setq done ...) (set-auto-mode-0 done keep-mode-if-same)))
  (unless done (if (setq done ...) (set-auto-mode-0 done keep-mode-if-same)))
  (let (end done mode modes) (save-excursion (goto-char ...) (skip-chars-forward " 	\n") (and enable-local-variables ... ...)) (if modes (catch ... ...)) (unless done (setq mode ... done ...) (if done ...)) (unless done (if ... ...)) (unless done (if buffer-file-name ...)) (unless done (if ... ...)))
  set-auto-mode()
  (progn (set-auto-mode))
  (if debug-on-error (progn (set-auto-mode)) (condition-case err (progn ...) (error ...)))
  (report-errors "File mode specification error: %s" (set-auto-mode))
  (let ((enable-local-variables ...)) (report-errors "File mode specification error: %s" (set-auto-mode)) (report-errors "Project local-variables error: %s" (hack-project-variables)) (report-errors "File local-variables error: %s" (hack-local-variables)))
  normal-mode(t)
  (if nomodes nil (when (and view-read-only view-mode) (view-mode-disable)) (normal-mode t) (and (memq require-final-newline ...) (> ... ...) (/= ... 10) (not ...) (save-excursion ... ...)) (when (and buffer-read-only view-read-only ...) (view-mode-enter)) (run-hooks (quote find-file-hook)))
  (unless nomodes (when (and view-read-only view-mode) (view-mode-disable)) (normal-mode t) (and (memq require-final-newline ...) (> ... ...) (/= ... 10) (not ...) (save-excursion ... ...)) (when (and buffer-read-only view-read-only ...) (view-mode-enter)) (run-hooks (quote find-file-hook)))
  after-find-file(nil t)
  find-file-noselect-1(#<buffer test> "/tmp/test" nil nil "/tmp/test" (251763 2055))
  find-file-noselect("/tmp/test" nil nil t)
  find-file("/tmp/test" t)
  call-interactively(find-file nil nil)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Unicode handling breaks Jpeg image detection?
  2008-06-25 12:37   ` Stephen Berman
@ 2008-07-04  7:20     ` Kenichi Handa
  2008-07-04  8:40       ` Stephen Berman
  0 siblings, 1 reply; 5+ messages in thread
From: Kenichi Handa @ 2008-07-04  7:20 UTC (permalink / raw)
  To: Stephen Berman; +Cc: emacs-devel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=ISO-2022-JP-2, Size: 820 bytes --]

Sorry for the late response.

In article <87tzfhadwr.fsf@escher.local.home>, Stephen Berman <stephen.berman@gmx.net> writes:

> This fix results in a file mode specification error.  To reproduce:
> 1. C-x C-f /tmp/test
> 2. Type the letter "^[$(D+#^[(B" (a-umlaut).
> 3. C-x C-s
> 4. C-x k RET
> 5. C-x C-f /tmp/test
> ==> File mode specification error: (error "Can't convert the 0th
> character to unibyte")

It seems that this bug is already fixed by Juanma (thanks).

2008-06-27  Juanma Barranquero  <lekktu@gmail.com>

	* image.el (image-jpeg-p): Don't fail if the arg cannot be converted
	to unibyte; just assume it is not a JPEG.  Use `string-match-p'.
	(image-type-from-data, image-type-from-file-name): Use `string-match-p'.
	(image-type-from-buffer): Use `looking-at-p'.

---
Kenichi Handa
handa@ni.aist.go.jp




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Unicode handling breaks Jpeg image detection?
  2008-07-04  7:20     ` Kenichi Handa
@ 2008-07-04  8:40       ` Stephen Berman
  0 siblings, 0 replies; 5+ messages in thread
From: Stephen Berman @ 2008-07-04  8:40 UTC (permalink / raw)
  To: emacs-devel

On Fri, 04 Jul 2008 16:20:26 +0900 Kenichi Handa <handa@m17n.org> wrote:

> Sorry for the late response.
>
> In article <87tzfhadwr.fsf@escher.local.home>, Stephen Berman <stephen.berman@gmx.net> writes:
>
>> This fix results in a file mode specification error.  To reproduce:
>> 1. C-x C-f /tmp/test
>> 2. Type the letter "ä" (a-umlaut).
>> 3. C-x C-s
>> 4. C-x k RET
>> 5. C-x C-f /tmp/test
>> ==> File mode specification error: (error "Can't convert the 0th
>> character to unibyte")
>
> It seems that this bug is already fixed by Juanma (thanks).
>
> 2008-06-27  Juanma Barranquero  <lekktu@gmail.com>
>
> 	* image.el (image-jpeg-p): Don't fail if the arg cannot be converted
> 	to unibyte; just assume it is not a JPEG.  Use `string-match-p'.
> 	(image-type-from-data, image-type-from-file-name): Use `string-match-p'.
> 	(image-type-from-buffer): Use `looking-at-p'.

Yes, I saw that.  Thanks from me too.

Steve Berman





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-07-04  8:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-24 20:23 Unicode handling breaks Jpeg image detection? Chong Yidong
2008-06-25  2:48 ` Kenichi Handa
2008-06-25 12:37   ` Stephen Berman
2008-07-04  7:20     ` Kenichi Handa
2008-07-04  8:40       ` Stephen Berman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).