MCPcopy Index your code
hub / github.com/textAngular/textAngular / validStyles

Function validStyles

src/textAngular-sanitize.js:513–592  ·  view source on GitHub ↗
(styleAttr)

Source from the content-addressed store, hash-verified

511// Currently allows only the color, background-color, text-align, float, width and height attributes
512// all other attributes should be easily done through classes.
513function validStyles(styleAttr){
514 var result = '';
515 var styleArray = styleAttr.split(';');
516 angular.forEach(styleArray, function(value){
517 var v = value.split(':');
518 if(v.length == 2){
519 var key = trim(angular.lowercase(v[0]));
520 var value = trim(angular.lowercase(v[1]));
521 if(
522 (key === 'color' || key === 'background-color') && (
523 value.match(/^rgb\([0-9%,\. ]*\)$/i)
524 || value.match(/^rgba\([0-9%,\. ]*\)$/i)
525 || value.match(/^hsl\([0-9%,\. ]*\)$/i)
526 || value.match(/^hsla\([0-9%,\. ]*\)$/i)
527 || value.match(/^#[0-9a-f]{3,6}$/i)
528 || value.match(/^[a-z]*$/i)
529 )
530 ||
531 key === 'text-align' && (
532 value === 'left'
533 || value === 'right'
534 || value === 'center'
535 || value === 'justify'
536 )
537 ||
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 ||
551 key === 'float' && (
552 value === 'left'
553 || value === 'right'
554 || value === 'none'
555 )
556 ||
557 key === 'vertical-align' && (
558 value === 'baseline'
559 || value === 'sub'
560 || value === 'super'
561 || value === 'test-top'
562 || value === 'text-bottom'
563 || value === 'middle'
564 || value === 'top'
565 || value === 'bottom'
566 || value.match(/[0-9]*(px|em)/)
567 || value.match(/[0-9]+?%/)
568 )
569 ||
570 key === 'font-size' && (

Callers 1

htmlSanitizeWriterFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected