unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Diane Murray <disumu@x3y2z1.net>
Subject: [Patch] url-http-create-request creates truncated paths
Date: Fri, 01 Sep 2006 01:25:38 +0200	[thread overview]
Message-ID: <87bqq01o99.fsf@x3y2z1.net> (raw)

Argument and value pairs separated by semicolons in URLs, parsed as
attributes in URL/Emacs, are being left out of HTTP requests.  This
results in 404 errors or the wrong page being retrieved.  For example,
the request for the URL
<http://www.emacswiki.org/cgi-bin/wiki?action=browse;oldid=Gnus;id=GnusPage>
is "GET /cgi-bin/wiki/?action=browse HTTP/1.1" - note that everything
following the first semicolon is ignored in the request.

Additionally, I believe - in http:// URLs, at least - the target (like
#top) belongs at the very end of the URL, yet `url-recreate-url'
places it just before any attributes.  Please see the following patch
for fixes.


	* url-parse.el (url-recreate-url-attributes): New function, code
	simply moved from `url-recreate-url'.
	(url-recreate-url): Use it.  Put the `url-target' at the end of
	the URL after the attributes.

	* url-http.el (url-http-create-request): Use
	`url-recreate-url-attributes' when setting real-fname.


Index: url-parse.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/url/url-parse.el,v
retrieving revision 1.11
diff -c -r1.11 url-parse.el
*** url-parse.el	5 Feb 2006 23:15:07 -0000	1.11
--- url-parse.el	31 Aug 2006 22:54:10 -0000
***************
*** 100,116 ****
  		   (not (equal (url-port urlobj)
  			       (url-scheme-get-property (url-type urlobj) 'default-port))))
  	      (format ":%d" (url-port urlobj)))
! 	  (or (url-filename urlobj) "/")
  	  (if (url-target urlobj)
! 	      (concat "#" (url-target urlobj)))
! 	  (if (url-attributes urlobj)
! 	      (concat ";"
! 		      (mapconcat
! 		       (function
! 			(lambda (x)
! 			  (if (cdr x)
! 			      (concat (car x) "=" (cdr x))
! 			    (car x)))) (url-attributes urlobj) ";")))))
  
  ;;;###autoload
  (defun url-generic-parse-url (url)
--- 100,120 ----
  		   (not (equal (url-port urlobj)
  			       (url-scheme-get-property (url-type urlobj) 'default-port))))
  	      (format ":%d" (url-port urlobj)))
! 	  (or (url-filename urlobj) "/")          
! 	  (url-recreate-url-attributes urlobj)
  	  (if (url-target urlobj)
! 	      (concat "#" (url-target urlobj)))))
! 
! (defun url-recreate-url-attributes (urlobj)
!   "Recreate the attributes of an URL string from the parsed URLOBJ."
!   (when (url-attributes urlobj)
!     (concat ";"
! 	    (mapconcat
! 	     (function
! 	      (lambda (x)
! 		(if (cdr x)
! 		    (concat (car x) "=" (cdr x))
! 		  (car x)))) (url-attributes urlobj) ";"))))
  
  ;;;###autoload
  (defun url-generic-parse-url (url)
Index: url-http.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/url/url-http.el,v
retrieving revision 1.30
diff -c -r1.30 url-http.el
*** url-http.el	12 May 2006 12:29:36 -0000	1.30
--- url-http.el	31 Aug 2006 22:52:34 -0000
***************
*** 160,166 ****
  		       (let ((url-basic-auth-storage
  			      'url-http-proxy-basic-auth-storage))
  			 (url-get-authentication url nil 'any nil))))
! 	 (real-fname (url-filename (or proxy-obj url)))
  	 (host (url-host (or proxy-obj url)))
  	 (auth (if (cdr-safe (assoc "Authorization" url-request-extra-headers))
  		   nil
--- 160,167 ----
  		       (let ((url-basic-auth-storage
  			      'url-http-proxy-basic-auth-storage))
  			 (url-get-authentication url nil 'any nil))))
! 	 (real-fname (concat (url-filename (or proxy-obj url))
! 			     (url-recreate-url-attributes (or proxy-obj url))))
  	 (host (url-host (or proxy-obj url)))
  	 (auth (if (cdr-safe (assoc "Authorization" url-request-extra-headers))
  		   nil

             reply	other threads:[~2006-08-31 23:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-31 23:25 Diane Murray [this message]
2006-09-01  2:32 ` [Patch] url-http-create-request creates truncated paths Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bqq01o99.fsf@x3y2z1.net \
    --to=disumu@x3y2z1.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).