X-Git-Url: http://git.kpe.io/?p=wol.git;a=blobdiff_plain;f=uri.lisp;fp=uri.lisp;h=7c38f304226c95c1c43d190cb8aadb25143fff39;hp=1011b1036dcd0e6a60f8d67753953dacaf04e4cc;hb=628dda3f26ad183880fea5871c37b9cfa33b425a;hpb=0c0d797b5e6c5afa9050b8021ea4729f4ab68aca diff --git a/uri.lisp b/uri.lisp index 1011b10..7c38f30 100644 --- a/uri.lisp +++ b/uri.lisp @@ -7,24 +7,23 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: July 2003 ;;;; -;;;; $Id: uri.lisp,v 1.6 2003/08/08 23:40:13 kevin Exp $ +;;;; $Id: uri.lisp,v 1.7 2003/08/09 21:42:24 kevin Exp $ ;;;; ;;;; This file and Wol are Copyright (c) 2003 by Kevin M. Rosenberg ;;;; ************************************************************************* (in-package #:wol) -(defun uri->recode-uri-sans-session-id (uri) - (let ((parsed-path (puri:uri-parsed-path uri))) - (cond - ((and (eq :absolute (first parsed-path)) - (is-raw-session-id (second parsed-path))) - (values (copy-uri uri :place t - :parsed-path - (list* :absolute (cddr parsed-path))) - (raw-session-id->session-id (second parsed-path)))) - (t - (values uri nil))))) +(defun req-recode-uri-sans-session-id (req) + (setq cl-user::r req) + (let ((ppath (puri:uri-parsed-path (request-uri req)))) + (when (is-raw-session-id (second ppath)) + (let ((new-path (list* (car ppath) (cddr ppath)))) + (setf (uri-parsed-path (request-uri req)) new-path) + (setf (uri-parsed-path (request-raw-uri req)) new-path)) + (setf (request-decoded-uri-path req) + (uridecode-string (uri-path (request-raw-uri req)))) + (raw-session-id->session-id (second ppath))))) (defun request-cookies (req) (aif (aserve-request req) @@ -37,24 +36,22 @@ (let ((name (project-name (entity-project ent)))) (cdr (assoc name cookies :test #'string-equal)))) -(defun url-session-key (url) - "Return a session key encoded in a URL" - nil) - (defun compute-uris (req ent) "Compute URI's of a request" - (compute-session req ent) - (multiple-value-bind (page plists query) - (decode-url (puri:uri-path (request-raw-uri req))) - (when page - (setf (request-page req) (base-page-name page ent))) - (when plists - (setf (request-plist req) (car plists)) - (setf (request-next-plists req) (cdr plists)) - (when (null page) - (awhen (getf (request-plist req) :page) - (setf (request-page req) it)))) - (setf (request-uri-query req) query))) + (let ((url-session-id (req-recode-uri-sans-session-id req))) + (compute-session req ent url-session-id) + + (multiple-value-bind (page plists query) + (decode-url (puri:uri-path (request-raw-uri req))) + (when page + (setf (request-page req) (base-page-name page ent))) + (when plists + (setf (request-plist req) (car plists)) + (setf (request-next-plists req) (cdr plists)) + (when (null page) + (awhen (getf (request-plist req) :page) + (setf (request-page req) it)))) + (setf (request-uri-query req) query)))) ;;; URI Functions @@ -91,12 +88,12 @@ (url-plist (append (list :page page) plist)) (prefix (project-prefix (entity-project ent)))) (concatenate 'string + prefix (if (and session (websession-key session) - (eq :url (websession-method session))) - (format nil "/~~~A~~/" (websession-key session)) + (not (eq :cookies (websession-method session)))) + (format nil "~~~A~~/" (websession-key session)) "") - prefix (if (null plist) (concatenate 'string page ".html") (concatenate 'string @@ -111,12 +108,12 @@ (let ((str (plist-to-compressed-string plist))) (if base64 (string-to-base64-string str :uri t) - (escape-uri-field str)))) + (uriencode-string str)))) (defun url-string-to-plist (str &key (base64 t)) (let ((decode (if base64 (base64-string-to-string str :uri t) - (unescape-uri-field str)))) + (uridecode-string str)))) (when decode (ignore-errors (compressed-string-to-plist decode)))))