(comment_string)
return comment_string
Validates a comment string.

  Remove comment terminators (e.g. */) from a string.

  TODO(user): Make a per-language validator. Allow non-dangerous symbols
  depending on language. e.g. */ is OK for Python but not PHP

  Args:
    comment_string: (str|unicode) input comment string
  Returns:
    (unicode) String with invalid character sequences removed
Validates a comment string.
Validates a comment string .
def ValidateAndSanitizeComment(comment_string):
  """Validates a comment string.

  Remove comment terminators (e.g. */) from a string.

  TODO(user): Make a per-language validator. Allow non-dangerous symbols
  depending on language. e.g. */ is OK for Python but not PHP

  Args:
    comment_string: (str|unicode) input comment string
  Returns:
    (unicode) String with invalid character sequences removed
  """
  # Strip anything which is known to be a comment terminator in any
  # supported language.
  invalid_strings = [u'/*',    # C-style Multi-line start
                     u'*/',    # C-style Multi-line end
                     u'\"""',  # Python Multiline string
                     u'///',   # Escaped comment begin
                     u'\\*',   # Escaped Multiline begin
                    ]

  # Hacky python 2 vs. 3 portability
  if ((sys.version_info[0] == 2 and isinstance(comment_string, str))
      or (sys.version_info[0] == 3 and isinstance(comment_string, bytes))):
    comment_string = comment_string.decode('utf-8')
  change_made = True
  while change_made:
    change_made = False
    # Save original length for easy comparision later
    beginning_length = len(comment_string)

    for substring in invalid_strings:
      # Replace all instances of substring with empty string
      comment_string = comment_string.replace(substring, '')

    # If the length of the string changed, then a replacement occurred.
    # We need to repeat the process until no changes occur
    if len(comment_string) != beginning_length:
      change_made = True

  return comment_string
def ValidateAndSanitizeComment ( comment_string ) : # Strip anything which is known to be a comment terminator in any # supported language. invalid_strings = [ u'/*' , # C-style Multi-line start u'*/' , # C-style Multi-line end u'\"""' , # Python Multiline string u'///' , # Escaped comment begin u'\\*' , # Escaped Multiline begin ] # Hacky python 2 vs. 3 portability if ( ( sys . version_info [ 0 ] == 2 and isinstance ( comment_string , str ) ) or ( sys . version_info [ 0 ] == 3 and isinstance ( comment_string , bytes ) ) ) : comment_string = comment_string . decode ( 'utf-8' ) change_made = True while change_made : change_made = False # Save original length for easy comparision later beginning_length = len ( comment_string ) for substring in invalid_strings : # Replace all instances of substring with empty string comment_string = comment_string . replace ( substring , '' ) # If the length of the string changed, then a replacement occurred. # We need to repeat the process until no changes occur if len ( comment_string ) != beginning_length : change_made = True return comment_string