# frozen_string_literal: true RSpec.describe :strip_tags do link :strip_tags, from: :ree_text context "general" do it { expect(strip_tags('<" hi')).to eq(%{<" hi}) expect(strip_tags("Wei<a onclick='alert(document.cookie);'/>rdos")).to eq("Wei<a onclick='alert(document.cookie);'/>rdos") expect(strip_tags("<<")).to eq( "<<") expect(strip_tags("This is <-- not\n a comment here.")).to eq(%{This is <-- not\n a comment here.}) # TODO: # expect(strip_tags("This has a ]]> here.")).to eq(%{This has a <![CDATA[]]> here.}) # expect(strip_tags("This has an unclosed ]] here...")).to eq(%{This has an unclosed <![CDATA[]] here...}) expect(strip_tags("")).to eq("") expect(strip_tags(" ")).to eq(" ") expect(strip_tags("Don't touch me")).to eq("Don't touch me") expect(strip_tags("<<")).to eq( "<<") expect(strip_tags("This is a test.")).to eq("This is a test.") expect(strip_tags("This has a here.")).to eq("This has a here.") expect(strip_tags("Frozen string with no tags".freeze)).to eq("Frozen string with no tags") expect(strip_tags("This is a test.\n\n\n\n

It no longer contains any HTML.

\n})) .to eq(%{This is a test.\n\n\n\nIt no longer contains any HTML.\n}) } end context "html escaping of the given string" do it { expect(strip_tags("test\r\nstring")).to eq("test\r\nstring") expect(strip_tags("&")).to eq("&") expect(strip_tags("&")).to eq("&") expect(strip_tags("&&")).to eq("&&") expect(strip_tags("omg <script>BOM</script>")).to eq("omg <script>BOM</script>") } end end