Sha256: 8e6fa426203949318a870bde17ce14488c4eedab75366d88d821fe0492abe6ae

Contents?: true

Size: 1.54 KB

Versions: 1

Compression:

Stored size: 1.54 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '../../spec_helper')

module Owasp
  module Esapi
    module Codec
      describe CssCodec do
        let (:codec) { Owasp::Esapi::Codec::CssCodec.new }

        it "should encode my '<' as \\3c" do
          m = codec.encode([],"<")
          m.should == '\\3c '
        end

        it "should decode \\abcdefg and replace the invliad code point" do
          s = "\\abcdefg"
          codec.decode(s).should == "\uFFFDg"
        end
        it "should encode 0x100 as \\100" do
          s = 0x100.chr(Encoding::UTF_8)
          m = codec.encode([],s[0])
          m.should == "\\100 "
        end

        it "should decode '\\<' to '<'" do
          m = codec.decode("\\<")
          m.should == "<"
        end

        it "should decode '\\41xyz' to Axyz" do
          m = codec.decode("\\41xyz")
          m.should == "Axyz"
        end

        it "should decode '\\000041abc' to 'Aabc'" do
          m = codec.decode("\\000041abc")
          m.should == "Aabc"
        end

        it "should decode '\\41 abc' to 'Aabc'" do
          m = codec.decode("\\41 abc")
          m.should == "Aabc"
        end

        it "should decode 'abc\\\nxyz' to 'abcxyz'" do
          m = codec.decode("abc\\\nxyz")
          m.should == "abcxyz"
        end

        it "should decode 'abc\\\r\nxyz' to 'abcxyz'" do
          m = codec.decode("abc\\\r\nxyz")
          m.should == "abcxyz"
        end

        it "should decode \\3c as <" do
          codec.decode("\\3c").should == "<"
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
owasp-esapi-ruby-0.30.0 spec/codec/css_codec_spec.rb