@@ -225,13 +225,13 @@ <h4 class="modal-title">Add New Members</h4>
225225 < div >
226226 < select id ="selectedGroup " name ="group " class ="form-control custom-dropdown ">
227227 {% for group in groups %}
228- < option value ="{% url 'addUserToGroup' group %} " > {{group}}</ option >
228+ < option value ="{{forloop.counter0}} " > {{group}}</ option >
229229 {% endfor %}
230230 </ select >
231231 </ div >
232232 </ div >
233233 < div class ="modal-footer ">
234- < button type ="button " class ="btn btn-primary " onclick ="javascript:location.href=document.getElementById ('selectedGroup').value "> Fill Request Form</ button >
234+ < button type ="button " class ="btn btn-primary " onclick ="navigateToSelectedGroup ('selectedGroup') "> Fill Request Form</ button >
235235 < button type ="button " class ="btn btn-primary " data-dismiss ="modal "> Close</ button >
236236 </ div >
237237 </ div >
@@ -248,12 +248,12 @@ <h4 class="modal-title">Select Group</h4>
248248 < div class ="modal-body ">
249249 < select id ="groupList " class ="form-control custom-dropdown " name ="groupName " style ="width: -moz-available;width: -webkit-fill-available; ">
250250 {% for group in groups %}
251- < option value ="{% url 'groupAccessList' group %} " > {{group}}</ option >
251+ < option value ="{{forloop.counter0}} " > {{group}}</ option >
252252 {% endfor %}
253253 </ select >
254254 </ div >
255255 < div class ="modal-footer ">
256- < button type ="button " class ="btn btn-primary " onclick ="javascript:location.href= document.getElementById ('groupList').value "> Proceed</ button >
256+ < button type ="button " class ="btn btn-primary " onclick ="navigateToSelectedGroup ('groupList') "> Proceed</ button >
257257 < button type ="button " class ="btn btn-primary " data-dismiss ="modal "> Close</ button >
258258 </ div >
259259 </ div >
@@ -288,6 +288,29 @@ <h4 class="modal-title">Select Group</h4>
288288 $ ( '.group-access-select-dropdown' ) . dropdown ( ) ;
289289 $ ( '.custom-dropdown' ) . dropdown ( ) ;
290290 } ) ;
291+
292+ // Server-rendered URL allowlists keyed by the dropdown's selectedIndex.
293+ // Navigation targets come from these JS literals (server-trusted reverses
294+ // of the named URLs below), never from DOM text — this removes the taint
295+ // flow that CodeQL js/xss-through-dom was flagging on the previous
296+ // <option value> reads.
297+ var SELECTED_GROUP_URLS = [ { % for group in groups % } { % url 'addUserToGroup' group as g_url % } "{{ g_url|escapejs }}" { % if not forloop . last % } , { % endif % } { % endfor % } ] ;
298+ var GROUP_LIST_URLS = [ { % for group in groups % } { % url 'groupAccessList' group as g_url % } "{{ g_url|escapejs }}" { % if not forloop . last % } , { % endif % } { % endfor % } ] ;
299+
300+ function navigateToSelectedGroup ( selectId ) {
301+ var sel = document . getElementById ( selectId ) ;
302+ if ( ! sel ) {
303+ return ;
304+ }
305+ var urls = selectId === 'selectedGroup' ? SELECTED_GROUP_URLS : ( selectId === 'groupList' ? GROUP_LIST_URLS : null ) ;
306+ if ( ! urls ) {
307+ return ;
308+ }
309+ var idx = sel . selectedIndex ;
310+ if ( idx >= 0 && idx < urls . length ) {
311+ window . location . assign ( urls [ idx ] ) ;
312+ }
313+ }
291314 </ script >
292315</ body >
293316
0 commit comments