File: test_encoding.rb

package info (click to toggle)
ruby-loofah 2.2.3-1%2Bdeb10u1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 452 kB
  • sloc: ruby: 2,153; makefile: 2
file content (20 lines) | stat: -rw-r--r-- 556 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# :coding: utf-8
require "helper"

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

  if String.new.respond_to?(:encoding)
    describe "scrub_fragment" do
      it "sets the encoding for html" do
        escaped = Loofah.scrub_fragment(UTF8_STRING, :escape).to_s
        assert_equal UTF8_STRING.encoding, escaped.encoding
      end

      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