Skip to content

Commit c183840

Browse files
committed
fix some dictionaries display blank because of unesccape dic title in header of mdx
1 parent 0d16623 commit c183840

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

mdict/static/mdict/js/base_func.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,17 @@ function html_escape(text,all){
7373
if(text==null){
7474
return "";
7575
}else if(all){
76-
return encodeURIComponent(text).replace(/[!'()*]/g, escape);
76+
return encodeURIComponent(text).replace(/[!'()*\n]/g, escape);
7777
}else{
7878
//返回字符实体
79-
return text.replace(/[<>'"&]/g, function(match, pos, originalText){
79+
return text.replace(/[<>'"&\n]/g, function(match, pos, originalText){
8080
switch(match){
8181
case "'":return "&apos;";
8282
case "<":return "&lt;";
8383
case ">":return "&gt;";
8484
case "&":return "&amp;";
8585
case "\"":return "&quot;";
86+
case "\n":return "";
8687
}
8788
});
8889
}

mdict/static/mdict/js/shelf.js

+1
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ function get_header(container, dic_pk, dic_name, type){
344344
}
345345

346346
function shelf_dic_btn(type1,type2){
347+
//从书架词典简介页面点击Search按钮打开单个词典的搜索
347348
if(type1==1){
348349
var dic_pk=$("#modal-shelf-dic").attr('data-pk');
349350
}else{

mdict/views.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1963,7 +1963,9 @@ def mdict_dic(request, *args):
19631963
if len(dics) > 0:
19641964
dic_pk = dics[0].pk
19651965
dic = MdictDic.objects.get(pk=dic_pk)
1966-
dic_name = dic.mdict_name
1966+
# dic_name = dic.mdict_name
1967+
dic_name = remove_html_tags(dic.mdict_name)
1968+
# dic_name中含有未转义字符导致前端页面解析错误
19671969
query = request.GET.get('query', '')
19681970
is_mb = is_mobile(request)
19691971

0 commit comments

Comments
 (0)