2014-11-03 22:20:21 +00:00
|
|
|
# -*- coding: binary -*-
|
|
|
|
|
|
|
|
module Msf
|
|
|
|
|
|
|
|
###
|
|
|
|
#
|
|
|
|
# Mult-byte character string option.
|
|
|
|
#
|
|
|
|
###
|
|
|
|
class OptString < OptBase
|
|
|
|
def type
|
|
|
|
return 'string'
|
|
|
|
end
|
|
|
|
|
2016-03-29 04:03:17 +00:00
|
|
|
def validate_on_assignment?
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
2014-11-03 22:20:21 +00:00
|
|
|
def normalize(value)
|
2016-03-16 11:44:02 +00:00
|
|
|
if (value.to_s =~ /^file:(.*)/)
|
2015-04-27 21:07:43 +00:00
|
|
|
path = $1
|
|
|
|
begin
|
|
|
|
value = File.read(path)
|
|
|
|
rescue ::Errno::ENOENT, ::Errno::EISDIR
|
|
|
|
value = nil
|
|
|
|
end
|
|
|
|
end
|
2014-11-03 22:20:21 +00:00
|
|
|
value
|
|
|
|
end
|
|
|
|
|
2016-05-23 19:56:19 +00:00
|
|
|
def valid?(value=self.value, check_empty: true)
|
2014-11-03 22:20:21 +00:00
|
|
|
value = normalize(value)
|
2016-05-23 19:56:19 +00:00
|
|
|
return false if check_empty && empty_required_value?(value)
|
2014-11-03 22:20:21 +00:00
|
|
|
return super
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|