From 13e8c4eeafcaf3bc1ae7df2b556bc4b70f35dd3f Mon Sep 17 00:00:00 2001 From: Matt Miller Date: Sat, 1 Oct 2005 06:15:39 +0000 Subject: [PATCH] text compressing description git-svn-id: file:///home/svn/incoming/trunk@2926 4d416f70-5f16-0410-b530-b9f4589650da --- lib/msf/base/serializer/readable_text.rb | 6 +++--- lib/rex/text.rb | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/msf/base/serializer/readable_text.rb b/lib/msf/base/serializer/readable_text.rb index 95b9f81967..8614767925 100644 --- a/lib/msf/base/serializer/readable_text.rb +++ b/lib/msf/base/serializer/readable_text.rb @@ -97,7 +97,7 @@ class ReadableText # Description output += "Description:\n" - output += word_wrap(mod.description) + output += word_wrap(Rex::Text.compress(mod.description)) output += "\n" # References @@ -150,7 +150,7 @@ class ReadableText # Description output += "Description:\n" - output += word_wrap(mod.description) + output += word_wrap(Rex::Text.compress(mod.description)) output += "\n\n" return output @@ -184,7 +184,7 @@ class ReadableText # Description output += "Description:\n" - output += word_wrap(mod.description) + output += word_wrap(Rex::Text.compress(mod.description)) output += "\n\n" return output diff --git a/lib/rex/text.rb b/lib/rex/text.rb index c5ef7e1e1c..07eec19c04 100644 --- a/lib/rex/text.rb +++ b/lib/rex/text.rb @@ -298,6 +298,14 @@ module Text raise ArgumentError, "Invalid class for value: #{value.class}" end end + + # + # Compresses a string, eliminating all superfluous whitespace before and + # after lines and eliminating all lines. + # + def self.compress(str) + str.gsub(/\n/m, ' ').gsub(/\s+/, ' ').gsub(/^\s+/, '').gsub(/\s+$/, '') + end end end