@@ -50,7 +50,7 @@ function attach_elastic_search_query_sphinx(data) {
50
50
var search_url = document . createElement ( 'a' ) ;
51
51
52
52
search_url . href = data . proxied_api_host + '/api/v2/search/' ;
53
- search_url . search = '?q=' + $ . urlencode ( query ) + '&project=' + project +
53
+ search_url . search = '?q=' + encodeURIComponent ( query ) + '&project=' + project +
54
54
'&version=' + version + '&language=' + language ;
55
55
56
56
/*
@@ -64,6 +64,21 @@ function attach_elastic_search_query_sphinx(data) {
64
64
}
65
65
} ;
66
66
67
+ var buildSection = function ( title , link , content ) {
68
+ var div_title = document . createElement ( "div" ) ;
69
+ var a_element = document . createElement ( "a" ) ;
70
+ a_element . href = link ;
71
+ a_element . innerHTML = title ;
72
+ div_title . appendChild ( a_element ) ;
73
+ html = div_title . outerHTML
74
+ for ( var i = 0 ; i < content . length ; i ++ ) {
75
+ var div_content = document . createElement ( "div" ) ;
76
+ div_content . innerHTML = content [ i ] ;
77
+ html += div_content . outerHTML ;
78
+ }
79
+ return html ;
80
+ } ;
81
+
67
82
search_def
68
83
. then ( function ( data ) {
69
84
var results = data . results || [ ] ;
@@ -80,7 +95,7 @@ function attach_elastic_search_query_sphinx(data) {
80
95
title = xss ( result . highlights . title [ 0 ] ) ;
81
96
}
82
97
83
- var link = result . path + "?highlight=" + $ . urlencode ( query ) ;
98
+ var link = result . path + "?highlight=" + encodeURIComponent ( query ) ;
84
99
85
100
var item = $ ( '<a>' , { 'href' : link } ) ;
86
101
@@ -126,7 +141,7 @@ function attach_elastic_search_query_sphinx(data) {
126
141
if ( current_block . type === "section" ) {
127
142
var section = current_block ;
128
143
var section_subtitle = section . title ;
129
- var section_subtitle_link = link + "#" + section . id ;
144
+ var section_subtitle_link = xss ( link + "#" + section . id ) ;
130
145
var section_content = [ section . content . substr ( 0 , MAX_SUBSTRING_LIMIT ) + " ..." ] ;
131
146
132
147
if ( section . highlights . title . length ) {
@@ -145,15 +160,11 @@ function attach_elastic_search_query_sphinx(data) {
145
160
}
146
161
}
147
162
148
- append_html_to_contents (
149
- contents ,
150
- section_template ,
151
- {
152
- section_subtitle_link : section_subtitle_link ,
153
- section_subtitle : section_subtitle ,
154
- section_content : section_content
155
- }
156
- ) ;
163
+ contents . append ( buildSection (
164
+ section_subtitle ,
165
+ section_subtitle_link ,
166
+ section_content
167
+ ) ) ;
157
168
}
158
169
159
170
// if the result is a sphinx domain object
0 commit comments