Method: Jamf::Utility#escape_xml

Defined in:
lib/jamf/utility.rb

#escape_xml(string) ⇒ String

Given a string of xml element text, escape any characters that would make XML unhappy.

* & => &
* " => "
* < => &lt;
* > => &gt;
* ' => &apos;

Parameters:

  • string (String)

    the string to make xml-compliant.

Returns:

  • (String)

    the xml-compliant string



447
448
449
# File 'lib/jamf/utility.rb', line 447

def escape_xml(string)
  string.gsub(/&/, '&amp;').gsub(/"/, '&quot;').gsub(/>/, '&gt;').gsub(/</, '&lt;').gsub(/'/, '&apos;')
end