mirror of https://github.com/layui/layui
fix(form-select): 修复 XSS 漏洞 (#1813)
parent
747c786040
commit
b94811ec09
|
@ -654,14 +654,13 @@ layui.define(['lay', 'layer', 'util'], function(exports){
|
||||||
if(hasEquals){
|
if(hasEquals){
|
||||||
dl.children('.' + CREATE_OPTION).remove();
|
dl.children('.' + CREATE_OPTION).remove();
|
||||||
}else{
|
}else{
|
||||||
// 和初始渲染保持行为一致
|
|
||||||
var textVal = $('<div>' + value +'</div>').text();
|
|
||||||
var createOptionElem = dl.children('.' + CREATE_OPTION);
|
var createOptionElem = dl.children('.' + CREATE_OPTION);
|
||||||
if(createOptionElem[0]){
|
if(createOptionElem[0]){
|
||||||
createOptionElem.attr('lay-value', value);
|
createOptionElem.attr('lay-value', value).html(util.escape(value));
|
||||||
createOptionElem.text(textVal);
|
|
||||||
}else{
|
}else{
|
||||||
dl.append('<dd class="' + CREATE_OPTION + '" lay-value="'+ value +'">' + textVal + '</dd>');
|
var ddElem = $('<dd>');
|
||||||
|
ddElem.addClass(CREATE_OPTION).attr('lay-value', value).html(util.escape(value));
|
||||||
|
dl.append(ddElem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
@ -722,7 +721,9 @@ layui.define(['lay', 'layer', 'util'], function(exports){
|
||||||
|
|
||||||
if(isCreatable && othis.hasClass(CREATE_OPTION)){
|
if(isCreatable && othis.hasClass(CREATE_OPTION)){
|
||||||
othis.removeClass(CREATE_OPTION);
|
othis.removeClass(CREATE_OPTION);
|
||||||
select.append('<option value="' + value + '">' + value + '</option>');
|
var optionElem = $('<option>');
|
||||||
|
optionElem.attr('value', value).text(othis.text());
|
||||||
|
select.append(optionElem);
|
||||||
}
|
}
|
||||||
|
|
||||||
othis.siblings().removeClass(THIS);
|
othis.siblings().removeClass(THIS);
|
||||||
|
|
Loading…
Reference in New Issue