[#10853] Why limit class def to a constant or colon node? — Charles Oliver Nutter <charles.nutter@...>

Is there a historical reason why I can't do something like these:

12 messages 2007/04/03

[#10933] Cannot build with extra library path if previous version already installed — <noreply@...>

Bugs item #10140, was opened at 2007-04-16 17:32

10 messages 2007/04/16
[#10934] Re: [ ruby-Bugs-10140 ] Cannot build with extra library path if previous version already installed — nobu@... 2007/04/16

Hi,

[#10960] Re: [ ruby-Bugs-10140 ] Cannot build with extra library path if previous version already installed — "Michal Suchanek" <hramrach@...> 2007/04/18

On 4/16/07, nobu@ruby-lang.org <nobu@ruby-lang.org> wrote:

[#10967] Re: [ ruby-Bugs-10140 ] Cannot build with extra library path if previous version already installed — Nobuyoshi Nakada <nobu@...> 2007/04/19

Hi,

[#10970] Re: [ ruby-Bugs-10140 ] Cannot build with extra library path if previous version already installed — "Michal Suchanek" <hramrach@...> 2007/04/19

On 4/19/07, Nobuyoshi Nakada <nobu@ruby-lang.org> wrote:> Hi,>> At Wed, 18 Apr 2007 20:21:44 +0900,> Michal Suchanek wrote in [ruby-core:10960]:> > Yes. And this should also apply to extensions. The mkmf tests are now> > fine but the extension is linked with -L/sw/lib before -L../..>> Indeed.>>> Index: configure.in> ===================================================================> --- configure.in (revision 12191)> +++ configure.in (working copy)> @@ -1385,5 +1385,4 @@ if test "$enable_rpath" = yes; then> fi>> -LDFLAGS="-L. $LDFLAGS"> AC_SUBST(ARCHFILE)>This would break the previous fix so I did not even try to apply this ^

[#11003] miniruby loads extensions from already installed ruby — <noreply@...>

Bugs item #10303, was opened at 2007-04-23 10:44

10 messages 2007/04/23

[#11025] gsub with backslash characters in replacement string — "Adam Bozanich" <adam.boz@...>

Hello, spotted this one the other day:

10 messages 2007/04/26

[ ruby-Bugs-10340 ] Net::HTTP encodes parameters improperly.

From: <noreply@...>
Date: 2007-04-24 15:49:57 UTC
List: ruby-core #11018
Bugs item #10340, was opened at 2007-04-24 15:49
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=1698&aid=10340&group_id=426

Category: Standard Library
Group: 1.8.5
Status: Open
Resolution: None
Priority: 3
Submitted By: Colin Curtin (perplexes)
Assigned to: Nobody (None)
Summary: Net::HTTP encodes parameters improperly.

Initial Comment:
While trying to post a web form with lots of checkboxes, I ran into the interesting problem that Hash's with arrays for values, when doing a Net::HTTP.post_form, does not work properly.

To illustrate:

"
require 'net/http'
require 'uri'

uri = URI.parse('http://ihateosx.com/~colin/post_test.php')
data = {'test[]' => ['one', 'two', 'three']}

response = Net::HTTP.post_form(uri, data)
print response.body
"

Results in: 

array(1) {
  ["test"]=>
  array(1) {
    [0]=>
    string(11) "onetwothree"
  }
}
=> nil

When we look around in net/http.rb, the problem becomes obvious:

def set_form_data(params, sep = '&')
      self.body = params.map {|k,v| "#{urlencode(k.to_s)}=#{urlencode(v.to_s)}" }.join(sep)
      self.content_type = 'application/x-www-form-urlencoded'
end

The method does not allow for arrays to be values in the params Hash. Array.to_s only appends strings together.

Without doing much research, I turn it into:

def set_form_data(params, sep = '&')
      params_array = params.map do |k,v| 
        v.inject([]){|c, val| c << "#{urlencode(k.to_s)}=#{urlencode(val.to_s)}"}.join(sep)
      end
      self.body = params_array.join(sep)
      self.content_type = 'application/x-www-form-urlencoded'
end

Which will take something like
 {'test[]' => ['one', 'two', 'three']}

and turn it into

test[]=one&test[]=two&test[]=three

Which is correct for array post parameters. And indeed the PHP test page shows it also:

array(1) {
  ["test"]=>
  array(3) {
    [0]=>
    string(3) "one"
    [1]=>
    string(3) "two"
    [2]=>
    string(5) "three"
  }
}
=> nil


So, what to do from here? This is my first Ruby bug report. Please be gentle. :)

----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=1698&aid=10340&group_id=426

In This Thread

Prev Next