123
123
\s+\s+apt-get update
Get:1 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Hit:2 http://de.archive.ubuntu.com/ubuntu focal InRelease
Building dependency tree...
'
end
it 'does not convert links' do
expect(body).to eq(html)
end
end
end
describe '.dynamic_image_size' do
context 'when called for image at absolute path' do
context 'with src attr last' do
it 'add max-width: 100% rule to style attr' do
expect(described_class.dynamic_image_size(<<~HTML.chomp)).to match(Regexp.new(<<~REGEX.chomp))
HTML
REGEX
end
end
context 'with src attr first' do
it 'add max-width: 100% rule to style attr' do
expect(described_class.dynamic_image_size(<<~HTML.chomp)).to match(Regexp.new(<<~REGEX.chomp))
HTML
REGEX
end
end
end
context 'when called for base64-encoded inline images' do
context 'with src attr last' do
it 'add max-width: 100% rule to style attr' do
expect(described_class.dynamic_image_size(<<~HTML.chomp)).to match(Regexp.new(<<~REGEX.chomp))
HTML
REGEX
end
end
context 'with src attr first' do
it 'add max-width: 100% rule to style attr' do
expect(described_class.dynamic_image_size(<<~HTML.chomp)).to match(Regexp.new(<<~REGEX.chomp))
HTML
REGEX
end
end
end
end
# Issue #2416 - html_sanitizer goes into loop for specific content
describe '.strict' do
context 'with strings that take a long time (>10s) to parse' do
before { allow(Timeout).to receive(:timeout).and_raise(Timeout::Error) }
it 'returns a timeout error message for the user' do
expect(described_class.strict(+'', true))
.to match(HtmlSanitizer::UNPROCESSABLE_HTML_MSG)
end
end
context 'with href links that contain square brackets' do
it 'correctly URL encodes them' do
expect(described_class.strict(+'example', true))
.to eq('example')
end
end
context 'with href links that contain http urls' do
it 'correctly URL encodes them' do
expect(described_class.strict(+'example', true))
.to eq('example')
end
end
context 'when HTML sanitizer is removing attributes/styles which are white listed. #4605' do
it 'does not remove whitelisted attributes width' do
expect(described_class.strict('123 |
123 |
actual content
' } let(:target) { 'actual content
' } it 'removes them' do expect(described_class.strict(source)).to eq(target) end end end describe '.cleanup' do context 'with strings that take a long time (>10s) to parse' do before { allow(Timeout).to receive(:timeout).and_raise(Timeout::Error) } it 'returns a timeout error message for the user' do expect(described_class.cleanup(+'')) .to match(HtmlSanitizer::UNPROCESSABLE_HTML_MSG) end end end end