fukamachi / caveman

Lightweight web application framework for Common Lisp.
http://8arrow.org/caveman/
776 stars 62 forks source link

Caveman2 _parsed error #30

Closed jeffma closed 10 years ago

jeffma commented 10 years ago

in defroute (getf _parsed :|user|) is not working, it return nil, i print _parsed to page it shows (:|user[name]| "asdsdfsd")

fukamachi commented 10 years ago

Show me your code.

jeffma commented 10 years ago

but i use it like this is ok (caveman2.nested-parameter:parse-parameters '(:|user[name]| "abc")) ===> (:|user| (:|name| "abc")) my full tmpl file is below:

<form action="/users/create" method="post">
  <% @with user %>
  <div class="row">
    <div class="small-12 large-6 columns">
      <label>User Name
        <input name="user[name]" type="text" placeholder="Pick a username" value="<% @var name %>" />
      </label>
    </div>
  </div>
  <div class="row">
    <div class="small-12 large-6 columns">
      <label>User Email
        <input name="user[email]" type="text" placeholder="Your Email" />
      </label>
    </div>
  </div>
  <div class="row">
    <div class="small-12 large-6 columns">
      <label>User Password
        <input name="user[password]" type="password" placeholder="Create a Password" />
      </label>
    </div>
  </div>
  <% @endwith %>
  <div class="row">
    <div class="small-12 large-6 columns">
      <input class="button expand" type="submit" value="Submit" />
    </div>
  </div>
</form>

my defroute is

(defroute ("/users/create" :method :POST) (&key _parsed)
    (format nil "~S" (getf _parsed :|user|)))

my environment is SBCL 1.1.18, ubuntu linux 14.04 LTS, locale is "en_US.UTF-8" it's a new project,i didn't import any other libs now,i like this framework very much,i plan to use it in production environment

jeffma commented 10 years ago

i think i've found the problem, log shows _parsed is this: _PARSED: (:|user%5Bname%5D| "asffsafsdafdsafd" :|user%5Bemail%5D| "" :|user%5Bpassword%5D| "") %5B and %5D should be [ and ] form field didn't decode

jeffma commented 10 years ago

this is network request from chrome

Remote Address:127.0.0.1:5000
Request URL:http://localhost:5000/users/create
Request Method:POST
Status Code:200 OK
Request Headersview source
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip,deflate,sdch
Accept-Language:zh-CN,zh;q=0.8,en;q=0.6
Cache-Control:max-age=0
Connection:keep-alive
Content-Length:74
Content-Type:application/x-www-form-urlencoded
Cookie:CLACK.SESSION=f919f7bd511aa65f49b28c1bb4cef36b04a5802b
Host:localhost:5000
Origin:http://localhost:5000
Referer:http://localhost:5000/users/sign_up
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/34.0.1847.116 Chrome/34.0.1847.116 Safari/537.36
Form Dataview parsed
user%5Bname%5D=11111111111asfdafd&user%5Bemail%5D=asfd&user%5Bpassword%5D=
Response Headersview source
Cache-Control:private
Connection:Keep-Alive
Content-Length:3
Content-Type:text/html; charset=utf-8
Date:Mon, 23 Jun 2014 06:16:22 GMT
Keep-Alive:timeout=20
Server:Hunchentoot 1.2.27
Set-Cookie:CLACK.SESSION=f919f7bd511aa65f49b28c1bb4cef36b04a5802b; path=/; expires=Mon, 13 Dec 2128 11:58:14 +0000
X-Content-Type-Options:nosniff
X-Frame-Options:DENY
jeffma commented 10 years ago

i found in clack (clack.request::parameters->plist "user%5Bname%5D=123") ===> (:|user%5Bname%5D| "123")

jeffma commented 10 years ago

i've fixed this problem in clack project and commit a pull request.

fukamachi commented 10 years ago

It looks good. I've merged it. Thanks for not only reporting but figuring it out.