ronin-support 0.2.0.rc1 → 0.2.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog.md +4 -0
- data/README.md +2 -1
- data/gemspec.yml +1 -1
- data/lib/ronin/extensions/kernel.rb +3 -1
- data/lib/ronin/extensions/string.rb +44 -45
- data/lib/ronin/formatting/extensions/binary/integer.rb +9 -3
- data/lib/ronin/formatting/extensions/binary/string.rb +0 -2
- data/lib/ronin/support/version.rb +1 -1
- data/spec/extensions/kernel_spec.rb +7 -7
- data/spec/extensions/string_spec.rb +2 -2
- metadata +3 -3
data/ChangeLog.md
CHANGED
@@ -14,9 +14,13 @@
|
|
14
14
|
* Added {Net.smtp_send_message}.
|
15
15
|
* Added {Net.http_status}.
|
16
16
|
* Added YARD `@api` tags to define the public, semi-public and private APIs.
|
17
|
+
* Renamed `Kernel#attempt` to {Kernel#try}.
|
17
18
|
* Allow `:method` to be used with {Net.http_ok?}.
|
18
19
|
* Fixed a bug in {Ronin::Network::HTTP.expand_url} where `:host` and `:port`
|
19
20
|
options were being overridden.
|
21
|
+
* Improved the performance of {Integer#bytes}.
|
22
|
+
* Only redefine {String#dump} for Ruby 1.8.x.
|
23
|
+
* Ruby >= 1.9.1 correctly hex-escapes special characters.
|
20
24
|
* Fixed a bug in {String#format_chars}, where it was not using `each_char`
|
21
25
|
for unicode characters.
|
22
26
|
* Deprecated {String#common_postfix}, in favor of {String#common_suffix}.
|
data/README.md
CHANGED
data/gemspec.yml
CHANGED
@@ -185,53 +185,52 @@ class String
|
|
185
185
|
return self[prefix.length...(length - postfix.length)]
|
186
186
|
end
|
187
187
|
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
188
|
+
if RUBY_VERSION < '1.9.'
|
189
|
+
ESCAPE_BYTES = {
|
190
|
+
0x00 => '\0',
|
191
|
+
0x07 => '\a',
|
192
|
+
0x08 => '\b',
|
193
|
+
0x09 => '\t',
|
194
|
+
0x0a => '\n',
|
195
|
+
0x0b => '\v',
|
196
|
+
0x0c => '\f',
|
197
|
+
0x0d => '\r',
|
198
|
+
0x22 => '\"',
|
199
|
+
0x5c => '\\'
|
200
|
+
}
|
201
|
+
|
202
|
+
#
|
203
|
+
# Dumps the string as a C-style string.
|
204
|
+
#
|
205
|
+
# @return [String]
|
206
|
+
# The C-style encoded version of the String.
|
207
|
+
#
|
208
|
+
# @example
|
209
|
+
# "hello\x00\073\x90\r\n".dump
|
210
|
+
# # => "hello\0;\x90\r\n"
|
211
|
+
#
|
212
|
+
# @note
|
213
|
+
# This method is only defined on Ruby 1.8.x.
|
214
|
+
#
|
215
|
+
# @api public
|
216
|
+
#
|
217
|
+
def dump
|
218
|
+
dumped_string = ''
|
219
|
+
|
220
|
+
each_byte do |b|
|
221
|
+
dumped_string << if (b >= 0x20 && b <= 0x7e)
|
222
|
+
b.chr
|
223
|
+
elsif ESCAPE_BYTES.has_key?(b)
|
224
|
+
ESCAPE_BYTES[b]
|
225
|
+
else
|
226
|
+
("\\x%.2X" % b)
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
return "\"#{dumped_string}\""
|
230
231
|
end
|
231
232
|
|
232
|
-
|
233
|
+
alias inspect dump
|
233
234
|
end
|
234
235
|
|
235
|
-
alias inspect dump
|
236
|
-
|
237
236
|
end
|
@@ -53,17 +53,23 @@ class Integer
|
|
53
53
|
case endian
|
54
54
|
when :little, :net
|
55
55
|
mask = 0xff
|
56
|
+
shift = 0
|
56
57
|
|
57
58
|
address_length.times do |i|
|
58
|
-
buffer << ((self & mask) >>
|
59
|
+
buffer << ((self & mask) >> shift)
|
60
|
+
|
59
61
|
mask <<= 8
|
62
|
+
shift += 8
|
60
63
|
end
|
61
64
|
when :big
|
62
|
-
|
65
|
+
shift = ((address_length - 1) * 8)
|
66
|
+
mask = (0xff << shift)
|
63
67
|
|
64
68
|
address_length.times do |i|
|
65
|
-
buffer << ((self & mask) >>
|
69
|
+
buffer << ((self & mask) >> shift)
|
70
|
+
|
66
71
|
mask >>= 8
|
72
|
+
shift -= 8
|
67
73
|
end
|
68
74
|
else
|
69
75
|
raise(ArgumentError,"invalid endian #{endian}")
|
@@ -2,28 +2,28 @@ require 'spec_helper'
|
|
2
2
|
require 'ronin/extensions/kernel'
|
3
3
|
|
4
4
|
describe Kernel do
|
5
|
-
it "should provide Kernel#
|
6
|
-
Kernel.should respond_to('
|
5
|
+
it "should provide Kernel#try" do
|
6
|
+
Kernel.should respond_to('try')
|
7
7
|
end
|
8
8
|
|
9
|
-
describe "#
|
9
|
+
describe "#try" do
|
10
10
|
it "should return the result of the block if nothing is raised" do
|
11
|
-
|
11
|
+
try { 2 + 2 }.should == 4
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should return nil if an exception is raised" do
|
15
|
-
|
15
|
+
try { 2 + 'a' }.should be_nil
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should rescue RuntimeError exceptions" do
|
19
19
|
lambda {
|
20
|
-
|
20
|
+
try { raise(RuntimeError,"something happened",caller) }
|
21
21
|
}.should_not raise_error(RuntimeError)
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should rescue StandardError exceptions" do
|
25
25
|
lambda {
|
26
|
-
|
26
|
+
try { raise(StandardError,"not allowed to do that",caller) }
|
27
27
|
}.should_not raise_error(StandardError)
|
28
28
|
end
|
29
29
|
end
|
@@ -167,11 +167,11 @@ describe String do
|
|
167
167
|
end
|
168
168
|
|
169
169
|
it "should dump strings containing non-printable characters" do
|
170
|
-
"hello\x90\x05\
|
170
|
+
"hello\x90\x05\xEF".dump.should == '"hello\x90\x05\xEF"'
|
171
171
|
end
|
172
172
|
|
173
173
|
it "should dump the string when calling the inspect method" do
|
174
|
-
"hello\x90\x05\
|
174
|
+
"hello\x90\x05\xEF".inspect.should == '"hello\x90\x05\xEF"'
|
175
175
|
end
|
176
176
|
end
|
177
177
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: ronin-support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease: 6
|
5
|
-
version: 0.2.0.
|
5
|
+
version: 0.2.0.rc2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Postmodern
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-06-07 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: chars
|
@@ -88,7 +88,7 @@ dependencies:
|
|
88
88
|
requirements:
|
89
89
|
- - ~>
|
90
90
|
- !ruby/object:Gem::Version
|
91
|
-
version: 0.
|
91
|
+
version: 0.7.0
|
92
92
|
type: :development
|
93
93
|
prerelease: false
|
94
94
|
version_requirements: *id007
|