Class: Honeybadger::Util::SQL Private
- Inherits:
-
Object
- Object
- Honeybadger::Util::SQL
- Defined in:
- lib/honeybadger/util/sql.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- EscapedQuotes =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
/(\\"|\\')/.freeze
- SQuotedData =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
/'(?:[^']|'')*'/.freeze
- DQuotedData =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
/"(?:[^"]|"")*"/.freeze
- NumericData =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
/\b\d+\b/.freeze
- Newline =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
/\n/.freeze
- Replacement =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"?".freeze
- EmptyReplacement =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"".freeze
- DoubleQuoters =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
/(postgres|sqlite|postgis)/.freeze
Class Method Summary collapse
- .force_utf_8(string) ⇒ Object private
- .obfuscate(sql, adapter) ⇒ Object private
Class Method Details
.force_utf_8(string) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
24 25 26 27 28 29 30 31 |
# File 'lib/honeybadger/util/sql.rb', line 24 def self.force_utf_8(string) string.encode( Encoding.find('UTF-8'), invalid: :replace, undef: :replace, replace: '' ) end |
.obfuscate(sql, adapter) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/honeybadger/util/sql.rb', line 13 def self.obfuscate(sql, adapter) force_utf_8(sql.dup).tap do |s| s.gsub!(EscapedQuotes, EmptyReplacement) s.gsub!(SQuotedData, Replacement) s.gsub!(DQuotedData, Replacement) if adapter =~ DoubleQuoters s.gsub!(NumericData, Replacement) s.gsub!(Newline, EmptyReplacement) s.squeeze!(' ') end end |