Skip to content

Commit 635ea6f

Browse files
authored
Merge pull request #114 from browserstack/fix-uri-encode
fix: added urlencode for every query param
2 parents 14c2b6b + 32e40ba commit 635ea6f

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

templates/EnigmaOps/allUserAccessList.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,21 +82,21 @@
8282
reqParams = []
8383
var allowTag = true;
8484
if(access_type.length){
85-
reqParams.push("accessTag="+access_type)
86-
reqParams.push("accessTagExact="+access_type)
85+
reqParams.push("accessTag="+encodeURIComponent(access_type))
86+
reqParams.push("accessTagExact="+encodeURIComponent(access_type))
8787
allowTag = false
8888
}
8989
for(var i = 0; i<fields.length; i++){
9090
if(fields[i].value && fields[i].value.trim().length)
9191
if(fields[i].id != "accessTag" || allowTag){
92-
reqParams.push(fields[i].id+"="+fields[i].value)
92+
reqParams.push(fields[i].id+"="+encodeURIComponent(fields[i].value))
9393
}
9494
}
95-
reqParams.push("responseType="+contentType)
95+
reqParams.push("responseType="+encodeURIComponent(contentType))
9696
reqParams.push("page="+String(page_number))
9797
url = new URL(window.location.href)
9898
if(url.searchParams.get("username")){
99-
reqParams.push("username="+url.searchParams.get("username"))
99+
reqParams.push("username="+encodeURIComponent(url.searchParams.get("username")))
100100
}
101101
urlBuilder = "userAccesses?" + reqParams.join("&");
102102
return urlBuilder;
@@ -171,7 +171,7 @@ <h4 id="header-title">`+access_type+` Accesses for User {{username}}</h4>`
171171
html_string += "<td>"+record["offboarding_date"]+"</td>"
172172
html_string += "<td>"+record["grantOwner"]+"</td>"
173173
html_string += "<td>"+record["revokeOwner"]+"</td>"
174-
html_string += "<td>{% if is_ops %} <a class=\"btn btn-primary\" target=\"_blank\" href=\"/individual_resolve?requestId="+record["requestId"]+"&ops_resolve=true\">ReGrant</a></td>{% endif %}"
174+
html_string += "<td>{% if is_ops %} <a class=\"btn btn-primary\" target=\"_blank\" href=\"/individual_resolve?requestId="+encodeURIComponent(record["requestId"])+"&ops_resolve=true\">ReGrant</a></td>{% endif %}"
175175
html_string += "<td>"+record["type"]+"</td>"
176176
html_string += "</tr>"
177177
}
@@ -191,7 +191,7 @@ <h4 id="header-title">`+access_type+` Accesses for User {{username}}</h4>`
191191

192192
$(document).on('click', '.revoke-button', function(){
193193
id = $(this).attr("id");
194-
urlBuilder = "/access/markRevoked?requestId="+id+"&username="+current_username
194+
urlBuilder = "/access/markRevoked?requestId="+encodeURIComponent(id)+"&username="+encodeURIComponent(current_username)
195195
$.ajax({url: urlBuilder,
196196
success: function(result){
197197
console.log("yes", id+"-revoke-button", id+"-access-status")
@@ -333,7 +333,7 @@ <h4 id="header-title">Access List for User {{username}}</h4>
333333
<td>{{item.grantOwner}}</td>
334334
<td>{{item.revokeOwner}}</td>
335335
<td>{% if is_ops %}
336-
<a class="btn btn-primary" target="_blank" href="/individual_resolve?requestId={{ item.requestId }}&ops_resolve=true">ReGrant</a></td>
336+
<a class="btn btn-primary" target="_blank" href="/individual_resolve?requestId={{ item.requestId|urlencode }}&ops_resolve=true">ReGrant</a></td>
337337
{% endif %}
338338
<td>{{item.access_type}}</td>
339339
</tr>

templates/EnigmaOps/allUsersList.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
if(data.status == 'success') {
5757
custom_alert.addClass('alert-success');
5858
$('.loading-spinner').css('visibility', 'hidden')
59-
window.location.href = "/access/userAccesses?username=" + data.username;
59+
window.location.href = "/access/userAccesses?username=" + encodeURIComponent(data.username);
6060
} else {
6161
custom_alert.addClass('alert-danger');
6262
setTimeout(() => {
@@ -214,7 +214,7 @@ <h4 class="modal-title"></h4>
214214
<td>{{ item.is_active }}</td>
215215
<td>{{ item.state }}</td>
216216
<td>
217-
<a target="_blank" class="nav-link" href="{% url 'allUserAccessList' %}?username={{ item.username }}" rel="noopener noreferrer nofollow">Link</a>
217+
<a target="_blank" class="nav-link" href="{% url 'allUserAccessList' %}?username={{ item.username|urlencode }}" rel="noopener noreferrer nofollow">Link</a>
218218
</td>
219219
<td>{{ item.offbaord_date }}</td>
220220
{% if viewDetails.allowOffboarding %}

templates/EnigmaOps/failureAdminRequests.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494

9595
$(`.${selector}`).each(function () {
9696
if ($(this).is(":checked"))
97-
reqParams.push(`requestId=${$(this).val()}`)
97+
reqParams.push(`requestId=${encodeURIComponent($(this).val())}`)
9898
});
9999

100100
if (reqParams.length == 0) {
@@ -182,9 +182,9 @@ <h4 class="card-title">{{request.request_id}}</h4>
182182
</div>
183183
<div class="col-4">
184184
<div class="row float-right">
185-
<a class="card-link btn btn-primary" style="margin-top: 10px;" href="/resolve_bulk?requestId={{ request.request_id }}">Resolve</a><br>
186-
<a class="card-link btn btn-danger" style="margin-top: 10px;" href="/ignore/decline?requestId={{ request.request_id }}">Mark Declined</a><br>
187-
<a class="card-link btn btn-warning" style="margin-top: 10px;" href="/ignore/approve?requestId={{ request.request_id }}">Mark Approved</a><br>
185+
<a class="card-link btn btn-primary" style="margin-top: 10px;" href="/resolve_bulk?requestId={{ request.request_id|urlencode }}">Resolve</a><br>
186+
<a class="card-link btn btn-danger" style="margin-top: 10px;" href="/ignore/decline?requestId={{ request.request_id|urlencode }}">Mark Declined</a><br>
187+
<a class="card-link btn btn-warning" style="margin-top: 10px;" href="/ignore/approve?requestId={{ request.request_id|urlencode }}">Mark Approved</a><br>
188188
</div>
189189
</div>
190190
</div>

templates/EnigmaOps/showAccessHistory.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ <h2 class="h5 no-margin-bottom">Access List</h2>
152152
<td>{{ item.status }}</td>
153153
<td>{{ item.accessReason }}</td>
154154
<td>{{ item.decline_reason }}</td>
155-
<td><a class="btn btn-primary" target="_blank" href="/individual_resolve?requestId={{ item.requestId }}">ReGrant</a></td>
155+
<td><a class="btn btn-primary" target="_blank" href="/individual_resolve?requestId={{ item.requestId|urlencode }}">ReGrant</a></td>
156156
</tr>
157157
{% endfor %}
158158
</tbody>

templates/celery_revoke_failure_email.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66

77
<BR/><BR/>
88
{% if access_tag %}
9-
<a target='_blank' href="{% url 'pendingFailure' %}?access_type={{ access_tag }}">View all failed grants</a>
9+
<a target='_blank' href="{% url 'pendingFailure' %}?access_type={{ access_tag|urlencode }}">View all failed grants</a>
1010
{% endif %}

0 commit comments

Comments
 (0)