<commit_before>require 'shellwords'

module Sigh
  # Resigns an existing ipa file
  class Resign
    def run(options, args)
      # get the command line inputs and parse those into the vars we need...
      ipa, signing_identity, provisioning_profiles = get_inputs(options, args)

      # ... then invoke our programmatic interface with these vars
      resign(ipa, signing_identity, provisioning_profiles)
    end

    def self.resign(ipa, signing_identity, provisioning_profiles)
      self.new.resign(ipa, signing_identity, provisioning_profiles)
    end

    def resign(ipa, signing_identity, provisioning_profiles)
      resign_path = find_resign_path
      signing_identity = find_signing_identity(signing_identity)

      unless provisioning_profiles.kind_of?(Enumerable)
        provisioning_profiles = [provisioning_profiles]
      end

      # validate that we have valid values for all these params, we don't need to check signing_identity because `find_signing_identity` will only ever return a valid value
      validate_params(resign_path, ipa, provisioning_profiles)

      provisioning_options = provisioning_profiles.map { |fst, snd| "-p #{[fst, snd].compact.join('=')}" }.join(' ')

      command = [
        resign_path.shellescape,
        ipa.shellescape,
        signing_identity.shellescape,
        provisioning_options.shellescape,
        ipa.shellescape<commit_msg>Fixed bug with the whole command being shell escaped, including the space between the param name and param value, so that just the param value is escaped<commit_after>require 'shellwords'

module Sigh
  # Resigns an existing ipa file
  class Resign
    def run(options, args)
      # get the command line inputs and parse those into the vars we need...
      ipa, signing_identity, provisioning_profiles = get_inputs(options, args)

      # ... then invoke our programmatic interface with these vars
      resign(ipa, signing_identity, provisioning_profiles)
    end

    def self.resign(ipa, signing_identity, provisioning_profiles)
      self.new.resign(ipa, signing_identity, provisioning_profiles)
    end

    def resign(ipa, signing_identity, provisioning_profiles)
      resign_path = find_resign_path
      signing_identity = find_signing_identity(signing_identity)

      unless provisioning_profiles.kind_of?(Enumerable)
        provisioning_profiles = [provisioning_profiles]
      end

      # validate that we have valid values for all these params, we don't need to check signing_identity because `find_signing_identity` will only ever return a valid value
      validate_params(resign_path, ipa, provisioning_profiles)

      provisioning_options = provisioning_profiles.map { |fst, snd| "-p #{[fst, snd].compact.map(&:shellescape).join('=')}" }.join(' ')

      command = [
        resign_path.shellescape,
        ipa.shellescape,
        signing_identity.shellescape,
        provisioning_options,# we are aleady shellescaping this above, when we create the provisioning_options from the provisioning_profiles
        ipa.shellescape
{'fraction_non_alphanumeric': 0.0690108445612882, 'fraction_numerical': 0.0, 'mean_word_length': 3.7786499215070646, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6049924', 'n_tokens_mistral': 855, 'n_tokens_neox': 860, 'n_words': 253}