From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Newsgroups: gmane.lisp.guile.user Subject: Re: Haunt serves some resources mistakenly as text/plain Date: Thu, 21 Dec 2017 14:25:19 +0100 Message-ID: <87efno6wn4.fsf@gnu.org> References: <7618df95-aba7-2e5b-6bb2-e6d6de427907@zoho.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1513862654 8142 195.159.176.226 (21 Dec 2017 13:24:14 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 21 Dec 2017 13:24:14 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) Cc: Guile User To: sirgazil , David Thompson Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Thu Dec 21 14:24:09 2017 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eS0pT-0001EU-EX for guile-user@m.gmane.org; Thu, 21 Dec 2017 14:24:07 +0100 Original-Received: from localhost ([::1]:50709 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS0rM-0005xE-Qd for guile-user@m.gmane.org; Thu, 21 Dec 2017 08:26:04 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50994) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eS0qs-0005wW-S8 for guile-user@gnu.org; Thu, 21 Dec 2017 08:25:36 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eS0qo-0002fV-7j for guile-user@gnu.org; Thu, 21 Dec 2017 08:25:34 -0500 Original-Received: from hera.aquilenet.fr ([141.255.128.1]:59777) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eS0qn-0002dA-Re for guile-user@gnu.org; Thu, 21 Dec 2017 08:25:30 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 4BA36FBD7; Thu, 21 Dec 2017 14:25:31 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at aquilenet.fr Original-Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dJjf2JVpzY8i; Thu, 21 Dec 2017 14:25:29 +0100 (CET) Original-Received: from ribbon (unknown [193.50.110.235]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 17860F175; Thu, 21 Dec 2017 14:25:23 +0100 (CET) X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 1 =?utf-8?Q?Niv=C3=B4se?= an 226 de la =?utf-8?Q?R?= =?utf-8?Q?=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu In-Reply-To: <7618df95-aba7-2e5b-6bb2-e6d6de427907@zoho.com> (sirgazil@zoho.com's message of "Sat, 16 Dec 2017 15:36:21 -0500") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 141.255.128.1 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:14384 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi there! sirgazil skribis: > When you create resources in Haunt whose URL paths contain dots beside > the dot before a file extension, it seems Haunt's web server will > always serve them as "text/plain". So, in the case of HTML pages, for > example, when you visit them in the Web browser, the browser won't > render the HTML, but display the HTML markup instead (within a PRE > element in a browser-generated HTML page). I noticed that too. The first patch attached fixes it (previously (file-extension "hello.es.html") would return "es.html", which has no associated MIME type). The second one is nice to have. Dave, could you consider applying them? :-) Cheers, Ludo=E2=80=99. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-serve-Fix-file-extension-so-that-the-right-MIME-type.patch >From 2526692ad80b78538cd37043bf20db2407b7a150 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Thu, 21 Dec 2017 14:16:14 +0100 Subject: [PATCH 1/2] serve: Fix 'file-extension' so that the right MIME type is chosen. Reported by sirgazil at . * haunt/serve/mime-types.scm (%file-ext-regexp): Remove. (file-extension): Rewrite using 'string-rindex'. --- haunt/serve/mime-types.scm | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/haunt/serve/mime-types.scm b/haunt/serve/mime-types.scm index 4c9c0f1..c625dd5 100644 --- a/haunt/serve/mime-types.scm +++ b/haunt/serve/mime-types.scm @@ -539,16 +539,10 @@ ("vrml" . x-world/x-vrml) ("wrl" . x-world/x-vrml)))) -(define %file-ext-regexp - (make-regexp "(\\.(.*)|[~%])$")) - -(define (file-extension file-name) - "Return the file extension for FILE-NAME, or #f if one is not -found." - (and=> (regexp-exec %file-ext-regexp file-name) - (lambda (match) - (or (match:substring match 2) - (match:substring match 1))))) +(define (file-extension file) + "Return the extension of FILE or #f if there is none." + (let ((dot (string-rindex file #\.))) + (and dot (substring file (+ 1 dot) (string-length file))))) (define (mime-type file-name) "Guess the MIME type for FILE-NAME based upon its file extension." -- 2.15.1 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0002-guix-Switch-to-Guile-2.2.patch >From 9c3dec45907dc731e655201e19da2a6fb1b72680 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Thu, 21 Dec 2017 14:19:50 +0100 Subject: [PATCH 2/2] guix: Switch to Guile 2.2. * guix.scm : Switch to GUILE-2.2. --- guix.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guix.scm b/guix.scm index d9f8f44..32b548a 100644 --- a/guix.scm +++ b/guix.scm @@ -61,7 +61,7 @@ ("pkg-config" ,pkg-config) ("texinfo" ,texinfo))) (inputs - `(("guile" ,guile-2.0))) + `(("guile" ,guile-2.2))) (propagated-inputs `(("guile-commonmark" ,guile-commonmark) ("guile-reader" ,guile-reader))) -- 2.15.1 --=-=-=--