Skip to content

Commit 6bf19c6

Browse files
committed
HTTP::ClientRequest: Should handle nils in params
When hashes for params contain nils, they should be converted to empty strings instead of crashing. * #to_s: Calls #to_s on vars_get and vars_post data * #set_encode_uri: Calls #to_s on its arg
1 parent 3a7dbd7 commit 6bf19c6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/rex/proto/http/client_request.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ def to_s
111111
end
112112

113113
opts['vars_get'].each_pair do |var,val|
114+
var = var.to_s
115+
val = val.to_s
116+
114117
qstr << '&' if qstr.length > 0
115118
qstr << (opts['encode_params'] ? set_encode_uri(var) : var)
116119
qstr << '='
@@ -129,6 +132,9 @@ def to_s
129132
end
130133

131134
opts['vars_post'].each_pair do |var,val|
135+
var = var.to_s
136+
val = val.to_s
137+
132138
pstr << '&' if pstr.length > 0
133139
pstr << (opts['encode_params'] ? set_encode_uri(var) : var)
134140
pstr << '='
@@ -220,7 +226,7 @@ def set_uri
220226
end
221227

222228
def set_encode_uri(str)
223-
a = str.dup
229+
a = str.to_s.dup
224230
opts['uri_encode_count'].times {
225231
a = Rex::Text.uri_encode(a, opts['uri_encode_mode'])
226232
}

0 commit comments

Comments
 (0)