Skip to content

Sanitize data to ASCII wherever we can #145

@simonvaucher

Description

@simonvaucher

Problem

  • Someone (from Rehovot) managed in a pure stroke of unbelievable luck to add an invisible character to the unsupported_since_zapp_sdk key on the prompt.
  • They invisible character was right-to-left-mark
  • Versionomy gem failed while parsing the value, which looks empty but it is not

Proposed Solution

  • Whenever we deal with a field that should be only ASCII characters, remove everything that's not an ASCII character.
  • Example
a = "\u200F";
puts a //      => ""
a.empty? // => false

encoding_options = {
  :invalid           => :replace,  # Replace invalid byte sequences  
  :undef             => :replace,  # Replace anything not defined in ASCII  
  :replace           => '',        # Use a blank for those replacements  
  :universal_newline => true       # Always break lines with \n  
}  
a.encode(Encoding.find('ASCII'), encoding_options)
puts a //      => ""
a.empty? // => true

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions