Fixes #5170. Enforces a max width, avoids negative widths. Thanks Oliver!
Related to r13769 git-svn-id: file:///home/svn/framework3/trunk@14093 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
4b4ef45e33
commit
467df77a50
|
@ -860,7 +860,7 @@ class Metasploit3 < Msf::Auxiliary
|
||||||
|
|
||||||
line = ""
|
line = ""
|
||||||
width = 30 # name field width
|
width = 30 # name field width
|
||||||
#twidth = 16 # table like display cell width
|
twidth = 32 # table like display cell width
|
||||||
|
|
||||||
fields_order.each {|k|
|
fields_order.each {|k|
|
||||||
if not output_data.has_key?(k)
|
if not output_data.has_key?(k)
|
||||||
|
@ -877,12 +877,14 @@ class Metasploit3 < Msf::Auxiliary
|
||||||
case a
|
case a
|
||||||
when Hash
|
when Hash
|
||||||
a.each{ |sk, sv|
|
a.each{ |sk, sv|
|
||||||
|
sk = truncate_to_twidth(sk, twidth)
|
||||||
content << sprintf(" %s%s: %s\n", sk, " "*([0,width-sk.length].max), sv)
|
content << sprintf(" %s%s: %s\n", sk, " "*([0,width-sk.length].max), sv)
|
||||||
}
|
}
|
||||||
content << "\n"
|
content << "\n"
|
||||||
when Array
|
when Array
|
||||||
a.each { |sv|
|
a.each { |sv|
|
||||||
sv = sv.to_s.strip
|
sv = sv.to_s.strip
|
||||||
|
sv = truncate_to_twidth(sv, twidth)
|
||||||
content << sprintf("%s%s", " " * 5, sv)
|
content << sprintf("%s%s", " " * 5, sv)
|
||||||
}
|
}
|
||||||
content << "\n"
|
content << "\n"
|
||||||
|
@ -906,6 +908,7 @@ class Metasploit3 < Msf::Auxiliary
|
||||||
when Hash
|
when Hash
|
||||||
content = ""
|
content = ""
|
||||||
v.each{ |sk, sv|
|
v.each{ |sk, sv|
|
||||||
|
sk = truncate_to_twidth(sk,twidth)
|
||||||
content << sprintf(" %s%s: %s\n", sk, " "*([0,width-sk.length].max), sv)
|
content << sprintf(" %s%s: %s\n", sk, " "*([0,width-sk.length].max), sv)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -934,6 +937,7 @@ class Metasploit3 < Msf::Auxiliary
|
||||||
:data => v
|
:data => v
|
||||||
)
|
)
|
||||||
|
|
||||||
|
k = truncate_to_twidth(k,twidth)
|
||||||
line << sprintf("%s%s: %s\n", k, " "*([0,width-k.length].max), v)
|
line << sprintf("%s%s: %s\n", k, " "*([0,width-k.length].max), v)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
@ -961,6 +965,10 @@ class Metasploit3 < Msf::Auxiliary
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def truncate_to_twidth(string,twidth)
|
||||||
|
string.slice(0..twidth-2)
|
||||||
|
end
|
||||||
|
|
||||||
def number_to_human_size(size,unit)
|
def number_to_human_size(size,unit)
|
||||||
size = size.first.to_i * unit.first.to_i
|
size = size.first.to_i * unit.first.to_i
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue