File: test_encoding.rb

package info (click to toggle)
ruby-loofah 2.25.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 488 kB
  • sloc: ruby: 4,176; makefile: 4
file content (34 lines) | stat: -rw-r--r-- 902 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# :coding: utf-8
# frozen_string_literal: true

require "helper"

class UnitTestEncoding < Loofah::TestCase
  UTF8_STRING = "日本語"

  if (+"").respond_to?(:encoding)
    describe "#scrub_html4_fragment" do
      it "sets the encoding for html" do
        escaped = Loofah.scrub_html4_fragment(UTF8_STRING, :escape).to_s

        assert_equal UTF8_STRING.encoding, escaped.encoding
      end
    end

    describe "#scrub_html5_fragment" do
      it "sets the encoding for html" do
        escaped = Loofah.scrub_html5_fragment(UTF8_STRING, :escape).to_s

        assert_equal UTF8_STRING.encoding, escaped.encoding
      end
    end if Loofah.html5_support?

    describe "#scrub_xml_fragment" do
      it "sets the encoding for xml" do
        escaped = Loofah.scrub_xml_fragment(UTF8_STRING, :escape).to_s

        assert_equal UTF8_STRING.encoding, escaped.encoding
      end
    end
  end
end