|
74 | 74 | ttFocus.$inject = []; |
75 | 75 | app.directive("ttFocus", ttFocus); |
76 | 76 |
|
77 | | - function ttMatch($timeout) { |
| 77 | + function ttMatch($timeout, $parse) { |
78 | 78 | return { |
79 | 79 | restrict: 'A', |
80 | 80 | require: 'ngModel', |
81 | 81 | link: function (scope, elem, attrs, ctrl) { |
| 82 | + var matchGetter = $parse(attrs.ttMatch); |
| 83 | + |
82 | 84 | function check() { |
83 | 85 | if (ctrl.$dirty) { |
84 | 86 | var thisVal = elem.val(); |
85 | | - var otherVal = scope.$eval(attrs.ttMatch); |
| 87 | + var otherVal = matchGetter(scope); |
86 | 88 | if (!thisVal || thisVal === otherVal) { |
87 | 89 | ctrl.$setValidity('ttMatch', true); |
88 | 90 | } |
|
102 | 104 | } |
103 | 105 | }; |
104 | 106 | } |
105 | | - ttMatch.$inject = ["$timeout"]; |
| 107 | + ttMatch.$inject = ["$timeout", "$parse"]; |
106 | 108 | app.directive("ttMatch", ttMatch); |
107 | 109 |
|
108 | 110 | function ttPropertyEditor(PathBase){ |
|
172 | 174 | app.directive("ttPagerSummary", ttPagerSummary); |
173 | 175 |
|
174 | 176 | function idmPager($sce) { |
| 177 | + function escapeHtml(value) { |
| 178 | + return String(value) |
| 179 | + .replace(/&/g, "&") |
| 180 | + .replace(/</g, "<") |
| 181 | + .replace(/>/g, ">") |
| 182 | + .replace(/\"/g, """) |
| 183 | + .replace(/'/g, "'"); |
| 184 | + } |
| 185 | + |
| 186 | + var allowedPagerHtml = { |
| 187 | + "<strong><<</strong>": true, |
| 188 | + "<strong><</strong>": true, |
| 189 | + "<strong>></strong>": true, |
| 190 | + "<strong>>></strong>": true |
| 191 | + }; |
| 192 | + |
| 193 | + function trustPagerText(text) { |
| 194 | + if (allowedPagerHtml[text]) { |
| 195 | + return $sce.trustAsHtml(text); |
| 196 | + } |
| 197 | + return $sce.trustAsHtml(escapeHtml(text)); |
| 198 | + } |
| 199 | + |
175 | 200 | function Pager(result, pageSize) { |
176 | 201 | function PagerButton(text, page, enabled, current) { |
177 | | - this.text = $sce.trustAsHtml(text + ""); |
| 202 | + this.text = trustPagerText(text); |
178 | 203 | this.page = page; |
179 | 204 | this.enabled = enabled; |
180 | 205 | this.current = current; |
|
235 | 260 | elem.on("click", function (e) { |
236 | 261 | if (prevent) { |
237 | 262 | e.preventDefault(); |
238 | | - $(attrs.ttConfirmClick).modal('show'); |
| 263 | + var selector = attrs.ttConfirmClick || ""; |
| 264 | + if (selector.indexOf("#") !== 0) { |
| 265 | + return; |
| 266 | + } |
| 267 | + var id = selector.substring(1); |
| 268 | + if (!/^[A-Za-z][\w\-:.]*$/.test(id)) { |
| 269 | + return; |
| 270 | + } |
| 271 | + var modalElem = document.getElementById(id); |
| 272 | + if (!modalElem) { |
| 273 | + return; |
| 274 | + } |
| 275 | + $(modalElem).modal('show'); |
239 | 276 | if (!cb) { |
240 | 277 | cb = function () { |
241 | 278 | $(this).off("confirm"); |
242 | 279 | prevent = false; |
243 | 280 | elem.trigger("click"); |
244 | 281 | }; |
245 | | - $(attrs.ttConfirmClick).on("confirm", cb); |
| 282 | + $(modalElem).on("confirm", cb); |
246 | 283 | } |
247 | 284 | } |
248 | 285 | }); |
|
0 commit comments