Skip to content

Commit dde3d7f

Browse files
authored
Merge pull request #964 from rdkleine/master
Support for font-style = italic and font-size = [size em/px/%] in sanitize function validStyles
2 parents 526f7a3 + 8b7f6f8 commit dde3d7f

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

src/textAngular-sanitize.js

+17-8
Original file line numberDiff line numberDiff line change
@@ -535,19 +535,28 @@ function validStyles(styleAttr){
535535
|| value === 'justify'
536536
)
537537
||
538-
key === 'text-decoration' && (
539-
value === 'underline'
540-
|| value === 'line-through'
541-
)
542-
|| key === 'font-weight' && (
543-
value === 'bold'
544-
)
545-
||
538+
key === 'text-decoration' && (
539+
value === 'underline'
540+
|| value === 'line-through'
541+
)
542+
||
543+
key === 'font-weight' && (
544+
value === 'bold'
545+
)
546+
||
547+
key === 'font-style' && (
548+
value === 'italic'
549+
)
550+
||
546551
key === 'float' && (
547552
value === 'left'
548553
|| value === 'right'
549554
|| value === 'none'
550555
)
556+
||
557+
key === 'font-size' && (
558+
value.match(/[0-9\.]*(px|em|rem|%)/)
559+
)
551560
||
552561
(key === 'width' || key === 'height') && (
553562
value.match(/[0-9\.]*(px|em|rem|%)/)

test/textAngularSanitize/sanitize.spec.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,13 @@ describe('HTML', function() {
5959
htmlParser('<!--FOOBAR-->', handler);
6060
expect(comment).toEqual('FOOBAR');
6161
});
62-
62+
63+
it('should parse font-style italic', function(){
64+
var html = '<span style="font-type:italic">';
65+
htmlParser(html, handler);
66+
expect(comment).toEqual(html);
67+
});
68+
6369
it('should throw an exception for invalid comments', function() {
6470
var caught=false;
6571
try {

0 commit comments

Comments
 (0)