Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: enctype problem in CGI

by thewebsi (Scribe)
on Nov 13, 2007 at 02:02 UTC ( [id://650424]=note: print w/replies, xml ) Need Help??


in reply to enctype problem in CGI

It's quite strange, and does seem like a bug. I don't have access to a newer version of CGI just now, so not sure if it's been fixed (no reference to it in the change log). But I did find a workaround for anyone who's interested:
>perl -e 'use CGI; print $CGI::VERSION;' 3.15 >perl -e "use CGI; print CGI::start_form({enctype=>'test'});" # Seems +broken <form method="post" action="" enctype="multipart/form-data" enctype="t +est"> >perl -e "use CGI ( -no_xhtml ); print CGI::start_form({enctype=>'test +'});" # A non-ideal solution <form method="post" action="" enctype="test"> >perl -e "use CGI; print CGI::startform({enctype=>'test'});" # Don't k +now why it works, but it does... <form method="post" action="" enctype="test">
Note that startform() is documented as an alias of start_form(), and the source code does seem to support that. I also got the same results with v3.11

Replies are listed 'Best First'.
Re^2: enctype problem in CGI
by avarus (Novice) on Apr 15, 2008 at 09:23 UTC
    I've just found this thread very useful so even though it is probably no help to the original poster I'll add another comment. The reason the suggested workaround works is pretty obvious with a glance at CGI.pm (line 1802 in my version 3.15):
    #### Method: start_form # synonym for startform 'start_form' => <<'END_OF_FUNC', sub start_form { $XHTML ? &start_multipart_form : &startform; } END_OF_FUNC
    So if not a bug this is at least a big shortcoming in the CGI.pm documentation, which claims that startform is a simple alias for start_form.

    And for all the numbnuts above who said "why not just use multipart every time". What??? Multipart encoding only works with POST. If Firefox sees:

    <method='get' enctype='multipart/form-data' />
    Then it ignores the encoding with a warning, and probably does what you want, but Konqueror will honour the encoding and ignore the method. Hence all your forms get POSTed. Hence if I have a simple search box on my site Konqeror users can't can't bookmark the results page, and if I hit reload I get a spurious warning about resubmitting form data. Vanilla GET/url-encoded forms are in the HTML spec for a reason and seeing comments along the lines of "I don't need them so you shouldn't either" makes me wonder what this community is coming to.

    OK, sorry, rant over. :-)

    TIM
    --
    #Tip: use 'no strict' to make those nasty errors vanish.

      I've moved away from Perl as a result of the underlying weaknesses which this issue uncovered for me.

      The success (for me, my business) of Perl as a development platform is critical to the support available, the reliability of the modules and inherent in both those, the community (e.g. perlMonks).

      For a long time, I not only enjoyed working in Perl, I really enjoyed being "part" (ok ... an "extra" of very small stature!) of the Perl community.

      However, when I came across the above issue it showed that there are issues with reliability and documentation (support). To be honest I think I could have managed with both of those if it hadn't been the attitude of more "senior" members who displayed no willingness to deal with anomaly - or gave no direction on resolving it.

      The fact that, 3 years later, this post is still being of some assistance/interest strongly supports this view.

      In retrospect, I'd still be a perl advocate if it had panned out differently: e.g.
      • problem highlighted
      • source of issue identified
      • minor tuition/wrist slap for me for hand-rolling
      • update of module and/or documentation
      • thread closed forever

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://650424]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2024-03-28 17:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found