Don't convert entities in script/style elements

In HTML the text of a script/style tag should be left untouched, no
entities must be converted. Doing so would break Javascript such as the
following:

    foo&&bar;

Such code is often the result of minifiers doing their dirty business.
This commit is contained in:
Yorick Peterse committed 2015-04-08 14:32:09 +02:00
1 parent 6a1010c287
commit 4bdc8a3fdc
2 files changed
+53 -7

No files matched your search

+32
View File
@@ -85,6 +85,38 @@ describe Oga::XML::Text do
node.text.should == [160].pack('U')
end
end
describe 'inside an HTML script element' do
before do
@element = Oga::XML::Element.new(:name => 'script')
@document = Oga::XML::Document.new(
:type => :html,
:children => [@element]
)
end
it 'does not decode any entities' do
@element.inner_text = '&foo;'
@element.inner_text.should == '&foo;'
end
end
describe 'inside an HTML style element' do
before do
@element = Oga::XML::Element.new(:name => 'style')
@document = Oga::XML::Document.new(
:type => :html,
:children => [@element]
)
end
it 'does not decode any entities' do
@element.inner_text = '&foo;'
@element.inner_text.should == '&foo;'
end
end
end
describe '#to_xml' do