* 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)
| 15870 | * @return {string} Normalized style value with dimensions applied. |
| 15871 | */ |
| 15872 | function dangerousStyleValue(name, value) { |
| 15873 | // Note that we've removed escapeTextForBrowser() calls here since the |
| 15874 | // whole string will be escaped when the attribute is injected into |
| 15875 | // the markup. If you provide unsafe user data here they can inject |
| 15876 | // arbitrary CSS which may be problematic (I couldn't repro this): |
| 15877 | // https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet |
| 15878 | // http://www.thespanner.co.uk/2007/11/26/ultimate-xss-css-injection/ |
| 15879 | // This is not an XSS hole but instead a potential CSS injection issue |
| 15880 | // which has lead to a greater discussion about how we're going to |
| 15881 | // trust URLs moving forward. See #2115901 |
| 15882 | |
| 15883 | var isEmpty = value == null || typeof value === 'boolean' || value === ''; |
| 15884 | if (isEmpty) { |
| 15885 | return ''; |
| 15886 | } |
| 15887 | |
| 15888 | var isNonNumeric = isNaN(value); |
| 15889 | if (isNonNumeric || value === 0 || isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name]) { |
| 15890 | return '' + value; // cast to string |
| 15891 | } |
| 15892 | |
| 15893 | if (typeof value === 'string') { |
| 15894 | value = value.trim(); |
| 15895 | } |
| 15896 | return value + 'px'; |
| 15897 | } |
| 15898 | |
| 15899 | module.exports = dangerousStyleValue; |
| 15900 | },{"4":4}],105:[function(_dereq_,module,exports){ |