Skip to content

Commit 4a892a6

Browse files
wasadeclaude
andcommitted
Fix XSS risks in templates (tojson escaping), remove unused replicate_text
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 1dff24b commit 4a892a6

4 files changed

Lines changed: 14 additions & 23 deletions

File tree

microsetta_interface/static/input_util.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,6 @@ function disableInputOnSubmit(form_selector, input_selector, disabled_text)
4141
});
4242
}
4343

44-
function replicate_text(input_selector, destination_selector) {
45-
$(input_selector).bind('input', function(){
46-
$(this).val(function(_, v){
47-
$(destination_selector).html(v);
48-
return v
49-
});
50-
});
51-
}
52-
5344
function select_class(input_selector, destination_selector, input_to_class) {
5445
$(input_selector).change(function(){
5546
$(this).val(function(_, v){

microsetta_interface/templates/new_results_page.jinja2

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,20 +1383,20 @@
13831383
state.dataset_type = new NamedExpression("Dataset-Type", "Loading...");
13841384
state.known_datasets = [];
13851385
1386-
state.taxonomy = "{{taxonomy}}";
1387-
state.alpha_metric = "{{alpha_metric}}";
1388-
state.beta_metric = "{{beta_metric}}";
1386+
state.taxonomy = {{taxonomy|tojson}};
1387+
state.alpha_metric = {{alpha_metric|tojson}};
1388+
state.beta_metric = {{beta_metric|tojson}};
13891389
//Just using test barcode because I can never remember a valid one.
13901390
// DONT MERGE WITH FAKE BARCODE HERE.
1391-
state.sample_id = "{{sample.sample_barcode}}";
1391+
state.sample_id = {{sample.sample_barcode|tojson}};
13921392
//state.sample_id = "000023984";
13931393
//state.sample_id = "000004220";
13941394
//state.sample_id = "000023127";
13951395
1396-
state.barcode_prefix = "{{barcode_prefix}}";
1397-
state.public_endpoint = "{{public_endpoint}}";
1396+
state.barcode_prefix = {{barcode_prefix|tojson}};
1397+
state.public_endpoint = {{public_endpoint|tojson}};
13981398
let sample_type = "oral";
1399-
if ("{{sample.sample_site}}" === "Stool")
1399+
if ({{sample.sample_site|tojson}} === "Stool")
14001400
sample_type="fecal";
14011401
state.sample_type = sample_type;
14021402

microsetta_interface/templates/sample_results.jinja2

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@
2323

2424
<link rel="stylesheet" type="text/css" href="/static/css/4_column_flex.css" />
2525
<script>
26-
let taxonomy = "{{taxonomy}}";
27-
let alpha_metric = "{{alpha_metric}}";
28-
let beta_metric = "{{beta_metric}}";
29-
let sampleId = "{{sample.sample_barcode}}";
30-
let barcodePrefix = "{{barcode_prefix}}";
26+
let taxonomy = {{taxonomy|tojson}};
27+
let alpha_metric = {{alpha_metric|tojson}};
28+
let beta_metric = {{beta_metric|tojson}};
29+
let sampleId = {{sample.sample_barcode|tojson}};
30+
let barcodePrefix = {{barcode_prefix|tojson}};
3131
var opt = {"renderer": "canvas", "actions": true}; /* Options for the Vega embedding */
32-
var sample_type = "{{sample.sample_site}}";
32+
var sample_type = {{sample.sample_site|tojson}};
3333
switch(sample_type) {
3434
case "Stool":
3535
sample_type = "gut";

microsetta_interface/templates/sitebase.jinja2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@
254254
<li><a class="dropdown-item" href="/accounts/{{ account_id }}/sources/{{ source_id }}/update_age_range">{{ _('Update Profile Age') }}</a></li>
255255
{% endif %}
256256
<li><a class="dropdown-item" href="/accounts/{{ account_id }}/sources/{{ source_id }}/consents">{{ _('Consent Documents') }}</a></li>
257-
<li><a class="dropdown-item" href="/accounts/{{ account_id }}/sources/{{ source_id }}/remove" onClick="return verifyDeleteSource('{{source_name}}');">{{ _('Delete This Profile') }}</a></li>
257+
<li><a class="dropdown-item" href="/accounts/{{ account_id }}/sources/{{ source_id }}/remove" onClick="return verifyDeleteSource({{source_name|tojson}});">{{ _('Delete This Profile') }}</a></li>
258258
</ul>
259259
</div>
260260
</div>

0 commit comments

Comments
 (0)