(result, searchterms)
| 136 | } |
| 137 | |
| 138 | function formatSearchResult(result, searchterms) { |
| 139 | var teaser = makeTeaser(escapeHTML(result.doc.body), searchterms); |
| 140 | teaser_count++; |
| 141 | |
| 142 | // The ?URL_MARK_PARAM= parameter belongs inbetween the page and the #heading-anchor |
| 143 | var url = doc_urls[result.ref].split("#"); |
| 144 | if (url.length == 1) { // no anchor found |
| 145 | url.push(""); |
| 146 | } |
| 147 | |
| 148 | // encodeURIComponent escapes all chars that could allow an XSS except |
| 149 | // for '. Due to that we also manually replace ' with its url-encoded |
| 150 | // representation (%27). |
| 151 | var searchterms = encodeURIComponent(searchterms.join(" ")).replace(/\'/g, "%27"); |
| 152 | |
| 153 | return '<a href="' + path_to_root + url[0] + '?' + URL_MARK_PARAM + '=' + searchterms + '#' + url[1] |
| 154 | + '" aria-details="teaser_' + teaser_count + '">' + result.doc.breadcrumbs + '</a>' |
| 155 | + '<span class="teaser" id="teaser_' + teaser_count + '" aria-label="Search Result Teaser">' |
| 156 | + teaser + '</span>'; |
| 157 | } |
| 158 | |
| 159 | function makeTeaser(body, searchterms) { |
| 160 | // The strategy is as follows: |
no test coverage detected