<commit_before>class Opendata::Agents::Nodes::ResourceController < ApplicationController
  include Cms::NodeFilter::View
  include Opendata::UrlHelper

  before_action :accept_cors_request
  before_action :set_dataset

  private
    def set_dataset
      @dataset_path = @cur_path.sub(/\/resource\/.*/, ".html")

      @dataset = Opendata::Dataset.site(@cur_site).public.
        filename(@dataset_path).
        first

      raise "404" unless @dataset
    end

  public
    def index
      redirect_to @dataset_path
    end

    def download
      @item = @dataset.resources.find_by id: params[:id], filename: params[:filename]
      @item.dataset.inc downloaded: 1

      send_file @item.file.path, type: @item.content_type, filename: @item.filename,
        disposition: :attachment, x_sendfile: true
    end
end
<commit_msg>params[:filename] ASCII-8BIT to UTF-8<commit_after>class Opendata::Agents::Nodes::ResourceController < ApplicationController
  include Cms::NodeFilter::View
  include Opendata::UrlHelper

  before_action :accept_cors_request
  before_action :set_dataset

  private
    def set_dataset
      @dataset_path = @cur_path.sub(/\/resource\/.*/, ".html")

      @dataset = Opendata::Dataset.site(@cur_site).public.
        filename(@dataset_path).
        first

      raise "404" unless @dataset
    end

  public
    def index
      redirect_to @dataset_path
    end

    def download
      @item = @dataset.resources.find_by id: params[:id], filename: params[:filename].force_encoding("utf-8")
      @item.dataset.inc downloaded: 1

      send_file @item.file.path, type: @item.content_type, filename: @item.filename,
        disposition: :attachment, x_sendfile: true
    end
end

{'fraction_non_alphanumeric': 0.10961313012895663, 'fraction_numerical': 0.006447831184056272, 'mean_word_length': 3.422279792746114, 'pattern_counts': {'":': 0, '<': 5, '<?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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6344050', 'n_tokens_mistral': 535, 'n_tokens_neox': 509, 'n_words': 113}