Potential fix for code scanning alert no. 6: Unsafe HTML constructed from library input#241
Conversation
…from library input Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Signed-off-by: Daniel Hart | ALifeInArtifyAI <238904666+projectedanx@users.noreply.github.com>
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
Code Review
This pull request refactors the calendar generation logic in js/jquery.cal.js to construct DOM elements dynamically using jQuery instead of concatenating raw HTML strings, which improves security and maintainability. The feedback suggests replacing the for...in loops used for iterating over months and years with safer alternatives, such as jQuery.each and a standard for loop, to prevent issues with prototype chain extensions and ensure correct iteration order.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: Daniel Hart | ALifeInArtifyAI <238904666+projectedanx@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: Daniel Hart | ALifeInArtifyAI <238904666+projectedanx@users.noreply.github.com>
|
|
||
| var tfootRow = jQuery('<tr></tr>'); | ||
| tfootRow.append(jQuery('<td colspan="2"></td>').append(jQuery('<span class="today"></span>').text(l10n_cal_today))); | ||
| tfootRow.append(jQuery('<td colspan="3"></td>').html(' ')); |
Potential fix for https://github.com/projectedanx/YOURLS/security/code-scanning/6
Best fix: stop constructing
yearselect(and adjacent select/day labels) via raw HTML string concatenation with dynamic values. Build DOM nodes with jQuery element constructors, and assign dynamic content with.text(...)(ornew Option(...)) so values are treated as text, not HTML.In
js/jquery.cal.js, insidenewDatepickerHTML()(around lines 86–99), replace:monthselect/yearselect<thead>appends using those stringswith safe DOM construction:
<select name="month">and<select name="year">elements viajQuery('<select ...>')<option>elements using.val(...)and.text(...).text(...)for localized labels.text(...)This preserves functionality while removing HTML injection risk from library input.
Suggested fixes powered by Copilot Autofix. Review carefully before merging.