diff --git a/src/actions.lisp b/src/actions.lisp index 096686d5..3e802d7d 100644 --- a/src/actions.lisp +++ b/src/actions.lisp @@ -204,7 +204,10 @@ situation (e.g. redirect, signal an error, etc.).")) (reblocks/request:get-parameters))) (params (list* (cons *action-string* action-code) - old-params))) + (remove *action-string* + old-params + :key #'car + :test #'string-equal)))) (concatenate 'string (get-path) ;; Current URL path "?" diff --git a/src/doc/changelog.lisp b/src/doc/changelog.lisp index 2c3d83cd..6b0e5b74 100644 --- a/src/doc/changelog.lisp +++ b/src/doc/changelog.lisp @@ -33,6 +33,24 @@ "REBLOCKS/SESSION:INIT") :external-links (("Ultralisp" . "https://ultralisp.org")) :external-docs ("https://40ants.com/log4cl-extras/")) + (0.54.0 2023-10-22 + """ +Added +===== + +Function REBLOCKS/REQUEST:GET-REMOTE-IP was added. + +Fixed +===== + +Now function REBLOCKS/ACTIONS:MAKE-ACTION-URL removed old `action` argument if it is present in the +current URL. This fixes the case when you want to make an action url from the callback processing +another action. + +JavaScript function `initiateFormAction` now does not overwrites whole options.args object, +but only replaces the keys corresponding to a form data fields. + +""") (0.53.0 2023-06-20 """ Changed diff --git a/src/doc/request.lisp b/src/doc/request.lisp index ec41f847..e708c97f 100644 --- a/src/doc/request.lisp +++ b/src/doc/request.lisp @@ -18,6 +18,7 @@ "HTTP" "AJAX" "HTML" + "IP" "JSON" "URL")) """ @@ -38,6 +39,7 @@ (reblocks/request:remove-header function) (reblocks/request:get-uri function) (reblocks/request:get-path function) + (reblocks/request:get-remote-ip function) (reblocks/request-handler:handle-request generic-function) (reblocks/request-handler:handle-ajax-request generic-function) (reblocks/request-handler:*request-timeout* variable) diff --git a/src/js/jquery/jquery.js b/src/js/jquery/jquery.js index 18832b95..f8371f7f 100644 --- a/src/js/jquery/jquery.js +++ b/src/js/jquery/jquery.js @@ -369,7 +369,7 @@ function initiateFormAction(actionCode, form, options) { var action_arguments = form.serializeObjectWithSubmit(); delete(action_arguments['action']); - options['args'] = action_arguments; + options['args'] = Object.assign({}, options.args || {}, action_arguments); options['method'] = options['method'] || form.attr('method'); initiateAction(actionCode, options); } diff --git a/src/request.lisp b/src/request.lisp index e7116223..dab2e3a5 100644 --- a/src/request.lisp +++ b/src/request.lisp @@ -27,6 +27,8 @@ (:import-from #:quri) (:import-from #:str #:split) + (:import-from #:lack.request + #:request-remote-addr) (:export #:get-parameters #:get-parameter @@ -42,7 +44,8 @@ #:get-path #:with-request #:pure-request-p - #:get-cookie)) + #:get-cookie + #:get-remote-ip)) (in-package #:reblocks/request) @@ -234,3 +237,10 @@ if there is an action involved (even if the user hits refresh)." ,result))) +(defun get-remote-ip (&key (request *request*)) + "Returns a possible user's IP. + + Note, it may not be reliable, because user might try to set these headers manually." + (or (get-header "x-real-ip" :request request) + (get-header "x-forwarded-for" :request request) + (request-remote-addr request)))