-
Notifications
You must be signed in to change notification settings - Fork 4
Revert 292 ritm1344510 #298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
864ddfd
e42eaf9
be4d1a4
de895cc
6ff2917
4bde335
f6a6e04
3c9d49c
15c6b5b
bf5ea1a
42414e9
c1adafb
1b8e26b
ffaf57f
bd71d90
3430411
64c5dfa
cd136d7
810dd16
2513c87
ac99e99
f6d4594
8dbd1ec
45a3dcf
07ab870
320b076
6a85cc5
f834969
5f1e228
32331b5
c07c35e
ab24f1a
30c513c
7f5a358
41f4005
b0ba36a
739e0a8
58d8849
66f7f53
fc5d781
141aab0
153d6fc
4618d2c
973cfda
5e28206
410f61f
49950fe
881fb5d
5cb563f
70c914a
562b46e
c772694
213799f
0563970
90fa0fb
05f134a
f7c3023
e4b8a5d
e1e088d
ec1fe60
36a79b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
|
|
||
| .pager-button { | ||
| display: inline-block; | ||
| padding: 8px 12px; | ||
| margin: 6px; | ||
| border: 2px solid #0004ff; /* blue border color */ | ||
| border-radius: 4px; /* rounded rectangle */ | ||
| background-color: transparent; /* no background color */ | ||
| color: #0004ff; /* blue text color */ | ||
| text-decoration: none; | ||
| cursor: pointer; | ||
| } | ||
|
|
||
| .pager-button-current { | ||
| display: inline-block; | ||
| padding: 8px 12px; | ||
| margin: 6px; | ||
| border: 2px solid #350111; /* blue border color */ | ||
| border-radius: 4px; /* rounded rectangle */ | ||
| background-color: transparent; /* no background color */ | ||
| color: #000000; /* blue text color */ | ||
| text-decoration: none; | ||
| cursor: initial; | ||
| } | ||
| .pager-button:hover { | ||
| background-color: #e2e6ea; /* light gray background color on hover */ | ||
| } | ||
|
|
||
|
|
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,152 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var urlParams = new URLSearchParams(window.location.search); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var page = urlParams.get("page") ?? 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var resultsPerPage = 20; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var offset = (page - 1) * resultsPerPage; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var totalResults = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // var searchEndpoint = new URL("{{site.searchgov.endpoint}}/api/v2/search/i14y"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // params = { affiliate: "{{site.searchgov.affiliate}}", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // access_key: "{{site.searchgov.access_key}}", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // query: urlParams.get('query') , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // offset: offset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var searchgovParams = document.getElementById("searchgov-params"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.log("searchgovParams is : " + searchgovParams); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var currentURL = new URL(window.location.href); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var searchEndpoint = new URL( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| searchgovParams.dataset.endpoint + "/api/v2/search/i14y" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| params = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| affiliate: searchgovParams.dataset.affiliate, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| access_key: searchgovParams.dataset.accessKey, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| query: urlParams.get("query"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| offset: offset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| searchResults.setAttribute("start", offset + 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var inputElement = document.getElementById("extended-search-field-small"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| inputElement.value = urlParams.get("query"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| inputElement.focus(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Object.keys(params).forEach(key => searchEndpoint.searchParams.append(key, params[key])); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fetch(searchEndpoint).then(function(res) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return res.json() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }).then(function(posts) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| totalResults = posts.web.total; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| //console.log("Total results are : " + totalResults); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| document.getElementById('search-params').innerHTML = encodeHTML(urlParams.get('query')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| document.getElementById("search-keyword").innerHTML = urlParams.get("query"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Check failureCode scanning / CodeQL Client-side cross-site scripting High
Cross-site scripting vulnerability due to
user-provided value Error loading related location Loading
Copilot AutofixAI 5 months ago To fix the issue, the user-provided value from Steps to fix:
Suggested changeset
1
assets/js/search.js
Copilot is powered by AI and may make mistakes. Always verify output.
Positive FeedbackNegative Feedback
Refresh and try again.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| document.getElementById("results-count").innerHTML = totalResults; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (posts.web.results.length > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var searchResults = document.getElementById("search-results"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (searchResults != null){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| //console.log("searchResults are not null and offset is : " + offset); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| searchResults.setAttribute("start", offset + 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.log("searchResults are null."); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| document.getElementById('search-results').classList.remove('display-none'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| document.getElementById('no-results').classList.add('display-none'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for (item in posts.web.results){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| render_result(` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <li class="padding-bottom-5 margin-top-4 usa-prose border-bottom-05 border-base-lightest"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <b class="title"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <a href="${posts.web.results[item]['url']}"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ${posts.web.results[item]['title'] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .replace(/\uE000/g, '<span class="bg-yellow">') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .replace(/\uE001/g, '</span>')}</a> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </b> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div> ${posts.web.results[item]['snippet'].replace(/\uE000/g, '<span class="bg-yellow">').replace(/\uE001/g, '</span>')} </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </li> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| `, true) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }).catch(function(ex) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.log('parsing failed', ex); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }).finally(function(e){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if(document.getElementById('search-results').childNodes.length == 0){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| document.getElementById('search-results').classList.add('display-none'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| document.getElementById('no-results').classList.remove('display-none'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| document.getElementById("results-header").classList.add("display-none"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| document.getElementById("pager").classList.add("display-none"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| document.getElementById("results-header").classList.remove("display-none"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| update_pager(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| function render_result(content, append = true){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const previous = document.getElementById('search-results').innerHTML; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| document.getElementById('search-results').innerHTML = (append == true) ? previous + content : content; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| function update_pager() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var page = urlParams.get("page") ?? 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var pager = document.getElementById("pager"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var pagerLinks = ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var totalPages = Math.ceil(totalResults / resultsPerPage); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pager.innerHTML = ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (page > 1){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pagerLinks += '<a href="' + getLinkToPage(1) + '" aria-label="First page" class="pager-button">First</a>'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (totalPages > 5 && page > 5) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pagerLinks += '<span style="font-weight: bold;" class="margin-2">...</span>'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var start = Math.max(2, page - 3); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for (var i = start; i < page; i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pagerLinks += '<a href="' + getLinkToPage(i) + '" aria-label="Page ' + i + '" class="pager-button">' + i + '</a>'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pagerLinks += '<span class="margin-2, pager-button-current">Page ' + page + " of " + totalPages + "</span>"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var end = Math.min((totalPages - 1), ((1*page) + 3)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for (var j = (1*page) + 1; j <= end; j++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pagerLinks += '<a href="' + getLinkToPage(j) + '" aria-label="Page ' + j + '" class="pager-button">' + j + '</a>'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (totalPages > 5 && page < totalPages - 4) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pagerLinks += '<span style="font-weight: bold;" class="margin-2">...</span>'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if( totalPages > 1 && page < totalPages){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pagerLinks += '<a href="' + getLinkToPage(totalPages) + '" aria-label="Last page" class="pager-button">Last</a>'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pagerLinks += '<div class="usa-footer__contact-info grid-row grid-gap"><div class="grid-col-auto"><p class="margin-top-0">Powered by <strong>Search.gov</strong></p></div></div>'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pager.innerHTML = pagerLinks; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Check failureCode scanning / CodeQL Client-side cross-site scripting High
Cross-site scripting vulnerability due to
user-provided value Error loading related location Loading
Copilot AutofixAI 5 months ago To fix the issue, we need to ensure that any user-controlled input is properly sanitized or encoded before being inserted into the DOM. The best approach here is to use the Specifically:
Suggested changeset
1
assets/js/search.js
Copilot is powered by AI and may make mistakes. Always verify output.
Positive FeedbackNegative Feedback
Refresh and try again.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| function getLinkToPage(pageNumber) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var searchParams = currentURL.searchParams; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (searchParams.has("page")) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| searchParams.set("page", pageNumber); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| searchParams.append("page", pageNumber); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return currentURL.toString(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| function encodeHTML(str) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return str.replace(/&/g, '&') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .replace(/</g, '<') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .replace(/>/g, '>') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .replace(/"/g, '"') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .replace(/'/g, '''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Check warning
Code scanning / CodeQL
Inclusion of functionality from an untrusted source Medium