Skip to content

Commit 31e1acc

Browse files
committed
Merge remote-tracking branch 'origin/release/10.8.7' into v10/dev
# Conflicts: # version.json
2 parents 11270ea + 35c51a0 commit 31e1acc

File tree

7 files changed

+73
-42
lines changed

7 files changed

+73
-42
lines changed

src/Directory.Packages.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<PackageVersion Include="Serilog.Sinks.Async" Version="1.5.0" />
4949
<PackageVersion Include="Serilog.Sinks.File" Version="5.0.0" />
5050
<PackageVersion Include="Serilog.Sinks.Map" Version="1.0.2" />
51-
<PackageVersion Include="SixLabors.ImageSharp" Version="2.1.7" />
51+
<PackageVersion Include="SixLabors.ImageSharp" Version="2.1.9" />
5252
<PackageVersion Include="SixLabors.ImageSharp.Web" Version="2.0.2" />
5353
<PackageVersion Include="Smidge.InMemory" Version="4.3.0" />
5454
<PackageVersion Include="Smidge.Nuglify" Version="4.2.1" />
@@ -64,4 +64,4 @@
6464
<PackageVersion Include="System.Security.Cryptography.Xml" Version="6.0.1" />
6565
<PackageVersion Include="System.Text.RegularExpressions" Version="4.3.1" />
6666
</ItemGroup>
67-
</Project>
67+
</Project>

src/Umbraco.Web.Common/Extensions/HttpContextExtensions.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ public static async Task<AuthenticateResult> AuthenticateBackOfficeAsync(this Ht
5959
await httpContext.AuthenticateAsync(Constants.Security.BackOfficeExternalAuthenticationType);
6060
}
6161

62+
// Update the HttpContext's user with the authenticated user's principal to ensure
63+
// that subsequent requests within the same context will recognize the user
64+
// as authenticated.
65+
if (result.Succeeded)
66+
{
67+
httpContext.User = result.Principal;
68+
}
69+
6270
return result;
6371
}
6472

src/Umbraco.Web.UI.Client/src/common/directives/components/media/umbmedianodeinfo.directive.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,7 @@
6969
editorService.mediaTypeEditor(editor);
7070
};
7171

72-
scope.openSVG = () => {
73-
var popup = window.open('', '_blank');
74-
var html = '<!DOCTYPE html><body><img src="' + scope.nodeUrl + '"/>' +
75-
'<script>history.pushState(null, null,"' + $location.$$absUrl + '");</script></body>';
76-
77-
popup.document.open();
78-
popup.document.write(html);
79-
popup.document.close();
80-
}
72+
scope.openSVG = () => mediaHelper.openSVG(scope.nodeUrl);
8173

8274
// watch for content updates - reload content when node is saved, published etc.
8375
scope.$watch('node.updateDate', function(newValue, oldValue){

src/Umbraco.Web.UI.Client/src/common/services/mediahelper.service.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @name umbraco.services.mediaHelper
44
* @description A helper object used for dealing with media items
55
**/
6-
function mediaHelper(umbRequestHelper, $http, $log) {
6+
function mediaHelper(umbRequestHelper, $http, $log, $location) {
77

88
//container of fileresolvers
99
var _mediaFileResolvers = {};
@@ -449,7 +449,29 @@ function mediaHelper(umbRequestHelper, $http, $log) {
449449
cropY2: options.crop ? options.crop.y2 : null
450450
})),
451451
"Failed to retrieve processed image URL for image: " + imagePath);
452-
}
452+
},
453+
454+
/**
455+
* @ngdoc function
456+
* @name umbraco.services.mediaHelper#openSVG
457+
* @methodOf umbraco.services.mediaHelper
458+
* @function
459+
*
460+
* @description
461+
* Opens an SVG file in a new window as an image file, to prevent any potential XSS exploits.
462+
*
463+
* @param {string} imagePath File path, ex /media/1234/my-image.svg
464+
*/
465+
openSVG: function (imagePath) {
466+
var popup = window.open('', '_blank');
467+
var html = '<!DOCTYPE html><body style="background-image: linear-gradient(45deg, #ccc 25%, transparent 25%), linear-gradient(135deg, #ccc 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #ccc 75%), linear-gradient(135deg, transparent 75%, #ccc 75%); background-size:30px 30px; background-position:0 0, 15px 0, 15px -15px, 0px 15px;">'
468+
+ '<img src="' + imagePath + '"/>'
469+
+ '<script>history.pushState(null, null,"' + $location.$$absUrl + '");</script></body>';
470+
471+
popup.document.open();
472+
popup.document.write(html);
473+
popup.document.close();
474+
}
453475

454476
};
455477
} angular.module('umbraco.services').factory('mediaHelper', mediaHelper);

src/Umbraco.Web.UI.Client/src/common/services/user.service.js

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ angular.module('umbraco.services')
33

44
var currentUser = null;
55
var lastUserId = null;
6+
var countdownCounter = null;
67

78
//this tracks the last date/time that the user's remainingAuthSeconds was updated from the server
89
// this is used so that we know when to go and get the user's remaining seconds directly.
@@ -43,6 +44,10 @@ angular.module('umbraco.services')
4344
}
4445
currentUser = usr;
4546
lastServerTimeoutSet = new Date();
47+
//don't start the timer if it is already going
48+
if (countdownCounter) {
49+
return;
50+
}
4651
//start the timer
4752
countdownUserTimeout();
4853
}
@@ -54,23 +59,23 @@ angular.module('umbraco.services')
5459
*/
5560
function countdownUserTimeout() {
5661

57-
$timeout(function () {
62+
countdownCounter = $timeout(function () {
5863

5964
if (currentUser) {
6065
//countdown by 5 seconds since that is how long our timer is for.
6166
currentUser.remainingAuthSeconds -= 5;
6267

63-
//if there are more than 30 remaining seconds, recurse!
64-
if (currentUser.remainingAuthSeconds > 30) {
68+
//if there are more than 20 remaining seconds, recurse!
69+
if (currentUser.remainingAuthSeconds > 20) {
6570

6671
//we need to check when the last time the timeout was set from the server, if
67-
// it has been more than 30 seconds then we'll manually go and retrieve it from the
72+
// it has been more than 20 seconds then we'll manually go and retrieve it from the
6873
// server - this helps to keep our local countdown in check with the true timeout.
6974
if (lastServerTimeoutSet != null) {
7075
var now = new Date();
7176
var seconds = (now.getTime() - lastServerTimeoutSet.getTime()) / 1000;
7277

73-
if (seconds > 30) {
78+
if (seconds > 20) {
7479

7580
//first we'll set the lastServerTimeoutSet to null - this is so we don't get back in to this loop while we
7681
// wait for a response from the server otherwise we'll be making double/triple/etc... calls while we wait.
@@ -95,18 +100,23 @@ angular.module('umbraco.services')
95100
if (Umbraco.Sys.ServerVariables.umbracoSettings.keepUserLoggedIn !== true) {
96101
//NOTE: the safeApply because our timeout is set to not run digests (performance reasons)
97102
angularHelper.safeApply($rootScope, function () {
98-
try {
99-
//NOTE: We are calling this again so that the server can create a log that the timeout has expired, we
100-
// don't actually care about this result.
101-
authResource.getRemainingTimeoutSeconds();
102-
}
103-
finally {
104-
userAuthExpired();
105-
}
103+
//NOTE: We are calling this again so that the server can create a log that the timeout has expired
104+
//and we will show the login screen as close to the server's timout time as possible
105+
authResource.getRemainingTimeoutSeconds().then(function (result) {
106+
setUserTimeoutInternal(result);
107+
108+
//the client auth can expire a second earlier as the client internal clock is behind
109+
if (result < 1) {
110+
userAuthExpired();
111+
}
112+
});
106113
});
114+
115+
//recurse the countdown!
116+
countdownUserTimeout();
107117
}
108118
else {
109-
//we've got less than 30 seconds remaining so let's check the server
119+
//we've got less than 20 seconds remaining so let's check the server
110120

111121
if (lastServerTimeoutSet != null) {
112122
//first we'll set the lastServerTimeoutSet to null - this is so we don't get back in to this loop while we
@@ -155,6 +165,7 @@ angular.module('umbraco.services')
155165

156166
lastServerTimeoutSet = null;
157167
currentUser = null;
168+
countdownCounter = null;
158169

159170
openLoginDialog(isLogout === undefined ? true : !isLogout);
160171
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="umb-image-preview" ng-controller="umbImagePreviewController as controller">
22
<img class="umb-image-preview--image" ng-if="vm.clientSide" ng-init="previewUrl = controller.getClientSideUrl(vm.clientSideData)" ng-src="{{previewUrl}}" alt="{{vm.name}}" />
3-
<a ng-if="!vm.clientSide" href="#" ng-href="{{vm.source}}" target="_blank" rel="noopener">
3+
<a ng-if="!vm.clientSide" href="" ng-attr-href="{{vm.extension !== 'svg' ? vm.source : undefined}}" ng-click="vm.extension === 'svg' && controller.openSVG(vm.source)" target="_blank" rel="noopener">
44
<img class="umb-image-preview--image" ng-init="previewUrl = controller.getThumbnail(vm.source)" ng-src="{{previewUrl}}" alt="{{vm.name}}" />
55
</a>
66
</div>
Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
2-
3-
4-
51
angular.module("umbraco")
6-
.controller("umbImagePreviewController",
7-
function (mediaHelper) {
2+
.controller("umbImagePreviewController",
3+
function (mediaHelper) {
4+
5+
var vm = this;
86

9-
var vm = this;
7+
vm.getThumbnail = function (source) {
8+
return mediaHelper.getThumbnailFromPath(source) || source;
9+
}
1010

11-
vm.getThumbnail = function(source) {
12-
return mediaHelper.getThumbnailFromPath(source) || source;
13-
}
14-
vm.getClientSideUrl = function(sourceData) {
15-
return URL.createObjectURL(sourceData);
16-
}
11+
vm.getClientSideUrl = function (sourceData) {
12+
return URL.createObjectURL(sourceData);
13+
}
1714

18-
});
15+
vm.openSVG = (source) => mediaHelper.openSVG(source);
16+
});

0 commit comments

Comments
 (0)