* Convert a value into the proper css writable value. The style name `name` * should be logical (no hyphens), as specified * in `CSSProperty.isUnitlessNumber`. * * @param {string} name CSS property name such as `topMargin`. * @param {*} value CSS property value such as `10px`. * @return {strin
(name, value, isCustomProperty)
| 14304 | * @return {string} Normalized style value with dimensions applied. |
| 14305 | */ |
| 14306 | function dangerousStyleValue(name, value, isCustomProperty) { |
| 14307 | // Note that we've removed escapeTextForBrowser() calls here since the |
| 14308 | // whole string will be escaped when the attribute is injected into |
| 14309 | // the markup. If you provide unsafe user data here they can inject |
| 14310 | // arbitrary CSS which may be problematic (I couldn't repro this): |
| 14311 | // https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet |
| 14312 | // http://www.thespanner.co.uk/2007/11/26/ultimate-xss-css-injection/ |
| 14313 | // This is not an XSS hole but instead a potential CSS injection issue |
| 14314 | // which has lead to a greater discussion about how we're going to |
| 14315 | // trust URLs moving forward. See #2115901 |
| 14316 | |
| 14317 | var isEmpty = value == null || typeof value === 'boolean' || value === ''; |
| 14318 | if (isEmpty) { |
| 14319 | return ''; |
| 14320 | } |
| 14321 | |
| 14322 | if (!isCustomProperty && typeof value === 'number' && value !== 0 && !(isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name])) { |
| 14323 | return value + 'px'; // Presumes implicit 'px' suffix for unitless numbers |
| 14324 | } |
| 14325 | |
| 14326 | return ('' + value).trim(); |
| 14327 | } |
| 14328 | |
| 14329 | var warnValidStyle = emptyFunction; |
| 14330 |
no outgoing calls
no test coverage detected