Skip to content

Commit 3388dea

Browse files
authored
Merge pull request #1244 from NASA-IMPACT/1101-bug-fix-quotes-not-escaped-in-titles
1101 bug fix quotes not escaped in titles
2 parents 32de8a6 + 2252750 commit 3388dea

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,9 @@ For each PR made, an entry should be added to this changelog. It should contain
100100
- Added universal search functionality tests
101101
- Created search pane filter tests
102102
- Added pattern application form tests with validation checks
103+
104+
- 1101-bug-fix-quotes-not-escaped-in-titles
105+
- Description: Title rules that include single quotes show up correctly in the sinequa frontend (and the COSMOS api) but not in the delta urls page.
106+
- Changes:
107+
- Added `escapeHtml` function in the `delta_url_list.js` file to handle special character escaping correctly.
108+
- Called this function while retrieving the titles in `getGeneratedTitleColumn()` and `getCuratedGeneratedTitleColumn()` functions.

sde_indexing_helper/static/js/delta_url_list.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,12 +1208,22 @@ function getCuratedScrapedTitleColumn() {
12081208
};
12091209
}
12101210

1211+
function escapeHtml(str) {
1212+
if (!str) return '';
1213+
return str
1214+
.replace(/&/g, '&')
1215+
.replace(/</g, '&lt;')
1216+
.replace(/>/g, '&gt;')
1217+
.replace(/"/g, '&quot;')
1218+
.replace(/'/g, '&#39;');
1219+
}
1220+
12111221
function getGeneratedTitleColumn() {
12121222
return {
12131223
data: "generated_title",
12141224
width: "20%",
12151225
render: function (data, type, row) {
1216-
return `<input type="text" class="form-control individual_title_input whiteText" value='${data}' data-generated-title-id=${row["generated_title_id"]
1226+
return `<input type="text" class="form-control individual_title_input whiteText" value="${escapeHtml(data)}" data-generated-title-id=${row["generated_title_id"]
12171227
} data-match-pattern-type=${row["match_pattern_type"]
12181228
} data-delta-urls-count=${row["delta_urls_count"]
12191229
} data-url=${remove_protocol(row["url"])} />`;
@@ -1226,7 +1236,7 @@ function getCuratedGeneratedTitleColumn() {
12261236
data: "generated_title",
12271237
width: "20%",
12281238
render: function (data, type, row) {
1229-
return `<input type="text" class="form-control individual_title_input whiteText" value='${data}' data-generated-title-id=${row["generated_title_id"]
1239+
return `<input type="text" class="form-control individual_title_input whiteText" value="${escapeHtml(data)}" data-generated-title-id=${row["generated_title_id"]
12301240
} data-match-pattern-type=${row["match_pattern_type"]
12311241
} data-curated-urls-count=${row["curated_urls_count"]
12321242
} data-url=${remove_protocol(row["url"])} />`;

0 commit comments

Comments
 (0)