code: def escape_attr(s):
      '''
      escape the given string such that it can be placed in an XML attribute, like:
  
          <foo bar='$value'>
  
      Args:
        s (str): the string to escape.
  
      Returns:
        str: the escaped string.
      '''
      esc = xml.sax.saxutils.quoteattr(s)
      esc = esc.encode('ascii', 'xmlcharrefreplace').decode('ascii')
      esc = RESTRICTED_CHARS.sub('', esc)
      return esf escape_attr(s):
      '''
      escape the given string such that it can be placed in an XML attribute, like:
  
          <foo bar='$value'>
  
      Args:
        s (str): the string to escape.
  
      Returns:
        str: the escaped string.
      '''
      esc = xml.sax.saxutils.quoteattr(s)
      esc = esc.encode('ascii', 'xmlcharrefreplace').decode('ascii')
      esc = RESTRICTED_CHARS.sub('', esc)
      return esc
docs: escape the given string such that it can be placed in an XML attribute, like:
  
          <foo bar='$value'>
  
      Args:
        s (str): the string to escape.
  
      Returns:
        str: the escaped string.