This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Commit 6476af8
committed
feat($http): JSONP requests now require a trusted resource URL
The $http service will reject JSONP requests that are not trusted by
`$sce` as "ResourceUrl".
This change makes is easier for developers to see clearly where in their
code they are making JSONP calls that may be to untrusted endpoings and
forces them to think about how these URLs are generated.
Be aware that this commit does not put any constraint on the parameters
that will be appended to the URL. Developers should be mindful of what
parameters can be attached and how they are generated.
Closes #11352
BREAKING CHANGE
All JSONP requests now require the URL to be trusted as resource URLs.
There are two approaches to trust a URL:
**Whitelisting with the `$sceDelegateProvider.resourceUrlWhitelist()`
method.**
You configure this list in a module configuration block:
```
appModule.config(['$sceDelegateProvider', function($sceDelegateProvider) {
$sceDelegateProvider.resourceUrlWhiteList([
// Allow same origin resource loads.
'self',
// Allow JSONP calls that match this pattern
'https://some.dataserver.com/**.jsonp?**`
]);
}]);
```
**Explicitly trusting the URL via the `$sce.trustAsResourceUrl(url)`
method**
You can pass a trusted object instead of a string as a URL to the `$http`
service:
```
var promise = $http.jsonp($sce.trustAsResourceUrl(url));
```1 parent 9d08b33 commit 6476af8
File tree
3 files changed
+101
-25
lines changed- docs/content/error/$http
- src/ng
- test/ng
3 files changed
+101
-25
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
7 | 11 | | |
8 | 12 | | |
9 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
379 | 379 | | |
380 | 380 | | |
381 | 381 | | |
382 | | - | |
383 | | - | |
| 382 | + | |
| 383 | + | |
384 | 384 | | |
385 | 385 | | |
386 | 386 | | |
| |||
802 | 802 | | |
803 | 803 | | |
804 | 804 | | |
805 | | - | |
| 805 | + | |
| 806 | + | |
806 | 807 | | |
807 | 808 | | |
808 | 809 | | |
| |||
881 | 882 | | |
882 | 883 | | |
883 | 884 | | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
884 | 892 | | |
885 | 893 | | |
886 | 894 | | |
| |||
948 | 956 | | |
949 | 957 | | |
950 | 958 | | |
951 | | - | |
952 | | - | |
| 959 | + | |
| 960 | + | |
953 | 961 | | |
954 | 962 | | |
955 | 963 | | |
| |||
1111 | 1119 | | |
1112 | 1120 | | |
1113 | 1121 | | |
1114 | | - | |
| 1122 | + | |
| 1123 | + | |
1115 | 1124 | | |
1116 | 1125 | | |
1117 | 1126 | | |
| |||
1123 | 1132 | | |
1124 | 1133 | | |
1125 | 1134 | | |
1126 | | - | |
| 1135 | + | |
| 1136 | + | |
1127 | 1137 | | |
1128 | 1138 | | |
1129 | 1139 | | |
| |||
1135 | 1145 | | |
1136 | 1146 | | |
1137 | 1147 | | |
1138 | | - | |
| 1148 | + | |
| 1149 | + | |
1139 | 1150 | | |
1140 | 1151 | | |
1141 | 1152 | | |
| |||
1146 | 1157 | | |
1147 | 1158 | | |
1148 | 1159 | | |
1149 | | - | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
1150 | 1168 | | |
1151 | 1169 | | |
1152 | | - | |
1153 | | - | |
| 1170 | + | |
| 1171 | + | |
1154 | 1172 | | |
1155 | 1173 | | |
1156 | 1174 | | |
| |||
1249 | 1267 | | |
1250 | 1268 | | |
1251 | 1269 | | |
1252 | | - | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
1253 | 1282 | | |
1254 | 1283 | | |
1255 | 1284 | | |
1256 | 1285 | | |
1257 | | - | |
1258 | 1286 | | |
1259 | 1287 | | |
1260 | 1288 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
289 | 289 | | |
290 | 290 | | |
291 | 291 | | |
292 | | - | |
| 292 | + | |
293 | 293 | | |
294 | | - | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
295 | 300 | | |
296 | 301 | | |
297 | 302 | | |
| 303 | + | |
298 | 304 | | |
299 | 305 | | |
300 | 306 | | |
301 | 307 | | |
302 | 308 | | |
303 | | - | |
| 309 | + | |
304 | 310 | | |
305 | 311 | | |
306 | 312 | | |
307 | | - | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
308 | 323 | | |
309 | | - | |
310 | | - | |
| 324 | + | |
| 325 | + | |
311 | 326 | | |
312 | 327 | | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
313 | 334 | | |
314 | 335 | | |
315 | 336 | | |
| |||
602 | 623 | | |
603 | 624 | | |
604 | 625 | | |
605 | | - | |
| 626 | + | |
606 | 627 | | |
607 | 628 | | |
608 | 629 | | |
| |||
1010 | 1031 | | |
1011 | 1032 | | |
1012 | 1033 | | |
1013 | | - | |
| 1034 | + | |
1014 | 1035 | | |
1015 | 1036 | | |
1016 | 1037 | | |
1017 | 1038 | | |
1018 | 1039 | | |
1019 | | - | |
| 1040 | + | |
1020 | 1041 | | |
1021 | 1042 | | |
1022 | 1043 | | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
1023 | 1067 | | |
1024 | 1068 | | |
1025 | 1069 | | |
| |||
1481 | 1525 | | |
1482 | 1526 | | |
1483 | 1527 | | |
1484 | | - | |
| 1528 | + | |
1485 | 1529 | | |
1486 | 1530 | | |
1487 | | - | |
| 1531 | + | |
1488 | 1532 | | |
1489 | 1533 | | |
1490 | 1534 | | |
| |||
0 commit comments