<commit_before>module SecureHeaders
  module ViewHelpers
    # Public: create a style tag using the content security policy nonce.
    # Instructs secure_headers to append a nonce to style/script-src directives.
    #
    # Returns an html-safe style tag with the nonce attribute.
    def nonced_style_tag(content_or_options, &block)
      nonced_tag(:style, content_or_options, block)
    end

    # Public: create a script tag using the content security policy nonce.
    # Instructs secure_headers to append a nonce to style/script-src directives.
    #
    # Returns an html-safe script tag with the nonce attribute.
    def nonced_javascript_tag(content_or_options, &block)
      nonced_tag(:script, content_or_options, block)
    end

    # Public: use the content security policy nonce for this request directly.
    # Instructs secure_headers to append a nonce to style/script-src directives.
    #
    # Returns a non-html-safe nonce value.
    def content_security_policy_nonce(type)
      case type
      when :script
        SecureHeaders.content_security_policy_script_nonce(@_request)
      when :style
        SecureHeaders.content_security_policy_style_nonce(@_request)
      end
    end

    private

    def nonced_tag(type, content_or_options, block)
      options = {}
      content = if block
        options = content_or_options<commit_msg>parameters to nonce functions should be optional<commit_after>module SecureHeaders
  module ViewHelpers
    # Public: create a style tag using the content security policy nonce.
    # Instructs secure_headers to append a nonce to style/script-src directives.
    #
    # Returns an html-safe style tag with the nonce attribute.
    def nonced_style_tag(content_or_options = nil, &block)
      nonced_tag(:style, content_or_options, block)
    end

    # Public: create a script tag using the content security policy nonce.
    # Instructs secure_headers to append a nonce to style/script-src directives.
    #
    # Returns an html-safe script tag with the nonce attribute.
    def nonced_javascript_tag(content_or_options = nil, &block)
      nonced_tag(:script, content_or_options, block)
    end

    # Public: use the content security policy nonce for this request directly.
    # Instructs secure_headers to append a nonce to style/script-src directives.
    #
    # Returns a non-html-safe nonce value.
    def content_security_policy_nonce(type)
      case type
      when :script
        SecureHeaders.content_security_policy_script_nonce(@_request)
      when :style
        SecureHeaders.content_security_policy_style_nonce(@_request)
      end
    end

    private

    def nonced_tag(type, content_or_options, block)
      options = {}
      content = if block
        options = content_or_options
{'fraction_non_alphanumeric': 0.0555756044749188, 'fraction_numerical': 0.0, 'mean_word_length': 3.2843894899536323, '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': '4312012', 'n_tokens_mistral': 790, 'n_tokens_neox': 775, 'n_words': 255}