Skip to content

Commit 9fbc8f8

Browse files
committed
Don't allow quotes in tab heading strings
1 parent 78b6b1a commit 9fbc8f8

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/client/js/directives/form.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ module fng.directives {
300300
}
301301
attrs += SecurityService.generateDisabledAttr(idStr, scope, { attr: "disable", attrRequiresValue: true }); // uib-tab expects 'disable="true"` rather than 'disabled="true"' or just disabled
302302
result.before = "";
303+
const cleanTitle = info.title.replace(/["']/g, '');
303304
if (info.hideable) {
304305
const templateId = `customTemplate_${idStr}.html`;
305306
// $parent.hideTab is needed in the template below because the uib-tab directive has an isolated scope,
@@ -308,23 +309,23 @@ module fng.directives {
308309
`<script type="text/ng-template" id="${templateId}">` +
309310
` <li ng-class="[{active: active, disabled: disabled}, classes]" class="uib-tab nav-item">` +
310311
` <div class="hideable-tab">` +
311-
` <span class="class="nav-link" data-ng-click="select($event)">${info.title}</span>&nbsp;` +
312-
` <button name="hide_${idStr}_btn" data-ng-click="$parent.hideTab($event, '${info.title}', '${info.hiddenTabArrayProp}')"` +
312+
` <span class="class="nav-link" data-ng-click="select($event)">${cleanTitle}</span>&nbsp;` +
313+
` <button name="hide_${idStr}_btn" data-ng-click="$parent.hideTab($event, '${cleanTitle}', '${info.hiddenTabArrayProp}')"` +
313314
` style="position: relative; z-index: 20;" type="button" class="close pull-right">` +
314315
` <span aria-hidden="true">×</span><span class="sr-only">Close</span>` +
315316
` </button>` +
316317
` </div>` +
317318
` </li>` +
318319
`</script>`;
319320
attrs += ` template-url="${templateId}"`;
320-
attrs += ` data-ng-show="!${info.hiddenTabArrayProp} || !${info.hiddenTabArrayProp}.includes('${info.title}')"`
321+
attrs += ` data-ng-show="!${info.hiddenTabArrayProp} || !${info.hiddenTabArrayProp}.includes('${cleanTitle}')"`
321322
} else {
322-
attrs += ` heading="${info.title}"`;
323+
attrs += ` heading="${cleanTitle}"`;
323324
}
324325
if (tabNo > 0) {
325326
attrs += ` active="tabs[${tabNo}].active"`;
326327
}
327-
result.before += `<uib-tab ${attrs} deselect="tabDeselect($event, $selectedIndex)" select="updateQueryForTab('${info.title}')"`;
328+
result.before += `<uib-tab ${attrs} deselect="tabDeselect($event, $selectedIndex)" select="updateQueryForTab('${cleanTitle}')"`;
328329
result.before += '>';
329330
result.after = '</uib-tab>';
330331
}

0 commit comments

Comments
 (0)