forked from rapid7/metasploit-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: Fix Reline ASCII-8BIT <-> UTF-8 issues
- Loading branch information
1 parent
953f6c1
commit bea0973
Showing
10 changed files
with
200 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# -*- coding: binary -*- | ||
|
||
require 'rex/ui/text/input/utf8_common' | ||
|
||
module Rex | ||
module Ui | ||
module Text | ||
|
||
require 'rex/io/stream_abstraction' | ||
|
||
### | ||
# | ||
# This class implements input against a socket. | ||
# | ||
### | ||
class Input::Utf8Buffer < Rex::Ui::Text::Input::Buffer | ||
|
||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# -*- coding: binary -*- | ||
|
||
module Rex | ||
module Ui | ||
module Text | ||
class Input::Utf8Common | ||
def self.with_utf8_encoding(&block) | ||
external_encoding_on_entry = ::Encoding.default_external | ||
::Encoding.default_external = ::Encoding::UTF_8 | ||
|
||
internal_encoding_on_entry = ::Encoding.default_internal | ||
::Encoding.default_internal = ::Encoding::UTF_8 | ||
|
||
begin | ||
return block.call | ||
rescue StandardError => e | ||
puts 'Input' | ||
puts caller | ||
elog('Failed to call block with UTF8 encoding', error: e) | ||
ensure | ||
::Encoding.default_external = external_encoding_on_entry | ||
::Encoding.default_internal = internal_encoding_on_entry | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# -*- coding: binary -*- | ||
|
||
require 'rex/ui/text/input/utf8_common' | ||
|
||
module Rex | ||
module Ui | ||
module Text | ||
|
||
### | ||
# | ||
# This class implements standard input using Reline against | ||
# standard input, and forces UTF8 encoding. It supports tab completion. | ||
# | ||
### | ||
class Input::Utf8Readline < Input::Readline | ||
|
||
def initialize(tab_complete_proc = nil) | ||
super | ||
puts 'Created new Readline object' | ||
end | ||
|
||
def pgets | ||
Rex::Ui::Text::Input::Utf8Common.with_utf8_encoding do | ||
super | ||
end | ||
end | ||
end | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# -*- coding: binary -*- | ||
|
||
require 'rex/ui/text/input/utf8_common' | ||
|
||
module Rex | ||
module Ui | ||
module Text | ||
|
||
### | ||
# | ||
# This class implements input against a socket. | ||
# | ||
### | ||
class Input::Utf8Socket < Rex::Ui::Text::Input::Socket | ||
|
||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# -*- coding: binary -*- | ||
|
||
require 'rex/ui/text/input/utf8_common' | ||
|
||
module Rex | ||
module Ui | ||
module Text | ||
|
||
### | ||
# | ||
# This class implements input against standard in. | ||
# | ||
### | ||
class Input::Utf8Stdio < Rex::Ui::Text::Input::Stdio | ||
|
||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# -*- coding: binary -*- | ||
|
||
module Rex | ||
module Ui | ||
module Text | ||
class Output::Utf8Common | ||
def self.with_utf8_encoding(&block) | ||
external_encoding_on_entry = ::Encoding.default_external | ||
::Encoding.default_external = ::Encoding::UTF_8 | ||
|
||
internal_encoding_on_entry = ::Encoding.default_internal | ||
::Encoding.default_internal = ::Encoding::UTF_8 | ||
|
||
begin | ||
return block.call | ||
rescue StandardError => e | ||
puts 'Output' | ||
puts caller | ||
elog('Failed to call block with UTF8 encoding', error: e) | ||
ensure | ||
::Encoding.default_external = external_encoding_on_entry | ||
::Encoding.default_internal = internal_encoding_on_entry | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# -*- coding: binary -*- | ||
|
||
require 'rex/ui/text/output/utf8_common' | ||
|
||
module Rex | ||
module Ui | ||
module Text | ||
|
||
### | ||
# | ||
# This class implements output against standard out. | ||
# | ||
### | ||
class Output::Utf8Stdio < Rex::Ui::Text::Output::Stdio | ||
|
||
def print_line(msg = '') | ||
Output::Utf8Common.with_utf8_encoding do | ||
super | ||
end | ||
end | ||
|
||
def print_raw(msg = '') | ||
Output::Utf8Common.with_utf8_encoding do | ||
super | ||
end | ||
end | ||
end | ||
|
||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters