Skip to content

Commit

Permalink
Merge pull request #787 from Orckestra/dev
Browse files Browse the repository at this point in the history
C1 CMS v6.11
  • Loading branch information
napernik authored Nov 8, 2021
2 parents b918360 + 85cf7da commit d051f94
Show file tree
Hide file tree
Showing 45 changed files with 788 additions and 255 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This is a basic workflow to help you get started with Actions

name: CI


# Controls when the action will run.
on:
issues:
types:
[opened]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: danhellem/github-actions-issue-to-work-item@master
env:
ado_token: "2fkdmowxykpxbjdesotpjddpvzodif5rd5vdsfrpxxsgrhuwmyiq"
github_token: "df9367d03c44f7cbae7cf24cbc20766fc165d4df"
ado_organization: "orckestra001"
ado_project: "OrckestraCommerce"
ado_area_path: "OrckestraCommerce"
ado_iteration_path: "OrckestraCommerce"
ado_wit: "Issue"
ado_new_state: "New"
ado_active_state: "Active"
ado_close_state: "Closed"
ado_bypassrules: true
8 changes: 6 additions & 2 deletions Composite.Workflows/C1Console/Tools/SetTimeZoneWorkflow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,13 @@ public SetTimeZoneWorkflow()

private void initializeCodeActivity_InitializeBindings_ExecuteCode(object sender, EventArgs e)
{
string label;
var tzs = TimeZoneInfo.GetSystemTimeZones().ToDictionary(systemTimeZone => systemTimeZone.Id, systemTimeZone =>
StringResourceSystemFacade.GetString("Composite.Plugins.TimezoneDisplayNames",
"TimezoneDisplayName." + systemTimeZone.Id));
StringResourceSystemFacade.TryGetString("Composite.Plugins.TimezoneDisplayNames",
"TimezoneDisplayName." + systemTimeZone.Id, out label)
? label
: systemTimeZone.DisplayName);

var bindings = new Dictionary<string, object>
{
{"TimeZones", tzs},
Expand Down
6 changes: 3 additions & 3 deletions Composite.Workflows/Composite.Workflows.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<RootNamespace>Composite</RootNamespace>
<AssemblyName>Composite.Workflows</AssemblyName>
<ProjectTypeGuids>{14822709-B5A1-4724-98CA-57A101D1B079};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
Expand Down Expand Up @@ -1373,8 +1373,8 @@
</PropertyGroup>
<Exec Condition="Exists('$(SolutionDir)\.git')" Command="git -C $(ProjectDir) rev-parse --abbrev-ref HEAD&gt; &quot;$(GitBranchFile)&quot;" />
<Exec Condition="Exists('$(SolutionDir)\.git')" Command="git -C $(ProjectDir) rev-parse HEAD&gt; &quot;$(GitCommitHashFile)&quot;" />
<Exec Condition="!Exists('$(SolutionDir)\.git')" Command="@echo unknown branch > &quot;$(GitBranchFile)&quot;" />
<Exec Condition="!Exists('$(SolutionDir)\.git')" Command="@echo unknown commit > &quot;$(GitCommitHashFile)&quot;" />
<Exec Condition="!Exists('$(SolutionDir)\.git')" Command="@echo unknown branch &gt; &quot;$(GitBranchFile)&quot;" />
<Exec Condition="!Exists('$(SolutionDir)\.git')" Command="@echo unknown commit &gt; &quot;$(GitCommitHashFile)&quot;" />
<PropertyGroup>
<GitBranch>$([System.IO.File]::ReadAllText("$(GitBranchFile)").Trim())</GitBranch>
<GitCommitHash>$([System.IO.File]::ReadAllText("$(GitCommitHashFile)").Trim())</GitCommitHash>
Expand Down
4 changes: 2 additions & 2 deletions Composite/AspNet/SiteMapHandler.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
Expand Down Expand Up @@ -188,7 +188,7 @@ private void WriteSiteMapList(XmlWriter writer, IEnumerable<CmsPageSiteMapNode>
}
else
{
hostnameUrl = "http://" + binding.Hostname;
hostnameUrl = $"{(binding.EnforceHttps ? "https" : "http")}://{binding.Hostname}";
}

writer.WriteString(hostnameUrl + "{0}/{1}{2}/sitemap.xml".FormatWith(
Expand Down
37 changes: 37 additions & 0 deletions Composite/AspNet/WebObjectActivator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System;

using Microsoft.Extensions.DependencyInjection;

namespace Composite.AspNet
{
internal class WebObjectActivator : IServiceProvider
{
private readonly IServiceProvider _inner;

public WebObjectActivator(IServiceProvider inner)
{
_inner = inner;
}

public object GetService(Type serviceType)
{
var service = _inner.GetService(serviceType);

// Multiple types from System.Web.dll have internal constructors
// Ignoring those types to have a better debugging experience
if (service == null
&& serviceType.Assembly != typeof(System.Web.IHttpModule).Assembly)
{
try
{
service = ActivatorUtilities.CreateInstance(_inner, serviceType);
}
catch (InvalidOperationException)
{
}
}

return service ?? Activator.CreateInstance(serviceType, true);
}
}
}
7 changes: 6 additions & 1 deletion Composite/Composite.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<AssemblyName>Composite</AssemblyName>
<ProjectTypeGuids>{14822709-B5A1-4724-98CA-57A101D1B079};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
Expand Down Expand Up @@ -210,6 +210,7 @@
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="AspNet\WebObjectActivator.cs" />
<Compile Include="AspNet\CmsPagesSiteMapPlugin.cs" />
<Compile Include="AspNet\CmsPageSiteMapProvider.cs" />
<Compile Include="AspNet\ICmsSiteMapNode.cs" />
Expand Down Expand Up @@ -249,6 +250,7 @@
<Compile Include="C1Console\RichContent\ContainerClasses\ContainerClassManager.cs" />
<Compile Include="C1Console\RichContent\ContainerClasses\EqualOrAntonymComparer.cs" />
<Compile Include="Core\EmptyDisposable.cs" />
<Compile Include="Core\HashingHelper.cs" />
<Compile Include="Core\Implementation\StatelessDataConnectionImplementation.cs" />
<Compile Include="Core\Instrumentation\DisposableResourceTracer.cs" />
<Compile Include="AspNet\Caching\DonutCacheEntry.cs" />
Expand All @@ -257,6 +259,9 @@
<Compile Include="Core\Serialization\CompositeJsonSerializer.cs" />
<Compile Include="Core\Serialization\CompositeSerializationBinder.cs" />
<Compile Include="Core\Types\CSharpCodeProviderFactory.cs" />
<Compile Include="Core\WebClient\Media\DefaultImageFileFormatProvider.cs" />
<Compile Include="Core\WebClient\Media\IImageFileFormatProvider.cs" />
<Compile Include="Core\WebClient\Media\ImageFormatProviders.cs" />
<Compile Include="Core\WebClient\PageStructureRpc.cs" />
<Compile Include="Core\WebClient\Renderings\Page\PagePreviewContext.cs" />
<Compile Include="Core\WebClient\Renderings\Page\IPageContentFilter.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,5 +141,7 @@ public string SerializedWorkflowsDirectory
public bool InheritGlobalReadPermissionOnHiddenPerspectives => false;

public bool OmitAspNetWebFormsSupport => false;

public bool ProtectResizedImagesWithHash => false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,8 @@ public static bool PrettifyRenderFunctionExceptions

public static bool OmitAspNetWebFormsSupport => UseReaderLock(p => p.OmitAspNetWebFormsSupport);

public static bool ProtectResizedImagesWithHash => UseReaderLock(p => p.ProtectResizedImagesWithHash);

private static void Flush()
{
_resourceLocker.ResetInitialization();
Expand Down
5 changes: 5 additions & 0 deletions Composite/Core/Configuration/GlobalSettingsFacade.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,11 @@ public static bool InheritGlobalReadPermissionOnHiddenPerspectives
/// </summary>
public static bool OmitAspNetWebFormsSupport => _globalSettingsFacade.OmitAspNetWebFormsSupport;

/// <summary>
/// When <value>true</value>, image URLs with resizing options will have a hash appended to ensure that the URLs are generated by the website.
/// </summary>
public static bool ProtectResizedImagesWithHash => _globalSettingsFacade.ProtectResizedImagesWithHash;

// Overload
/// <exclude />
public static CachingSettings GetNamedCaching(string name)
Expand Down
2 changes: 2 additions & 0 deletions Composite/Core/Configuration/GlobalSettingsFacadeImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,5 +168,7 @@ public void RemoveNonProbableAssemblyName(string assemblyNamePatern)
GlobalSettingsProviderPluginFacade.InheritGlobalReadPermissionOnHiddenPerspectives;

public bool OmitAspNetWebFormsSupport => GlobalSettingsProviderPluginFacade.OmitAspNetWebFormsSupport;

public bool ProtectResizedImagesWithHash => GlobalSettingsProviderPluginFacade.ProtectResizedImagesWithHash;
}
}
1 change: 1 addition & 0 deletions Composite/Core/Configuration/IGlobalSettingsFacade.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@ internal interface IGlobalSettingsFacade
TimeZoneInfo TimeZone { get; }
bool InheritGlobalReadPermissionOnHiddenPerspectives { get; }
bool OmitAspNetWebFormsSupport { get; }
bool ProtectResizedImagesWithHash { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,7 @@ internal interface IGlobalSettingsProvider
bool InheritGlobalReadPermissionOnHiddenPerspectives { get; }

bool OmitAspNetWebFormsSupport { get; }

bool ProtectResizedImagesWithHash { get; }
}
}
37 changes: 37 additions & 0 deletions Composite/Core/HashingHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System;
using System.Security.Cryptography;
using System.Text;

namespace Composite.Core
{
internal static class HashingHelper
{
[ThreadStatic]
private static MD5 _md5;

/// <summary>
/// Gets a cached instance of an MD5 algorithm
/// </summary>
private static MD5 MD5
{
get
{
var value = _md5;
if (value == null)
{
_md5 = value = MD5.Create();
}

return value;
}
}

public static Guid ComputeMD5Hash(string str, Encoding textEncoding)
{
var bytes = textEncoding.GetBytes(str);
var hash = MD5.ComputeHash(bytes);
return new Guid(hash);
}

}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
Expand All @@ -23,7 +23,7 @@ public sealed class DllPackageFragmentInstaller : BasePackageFragmentInstaller
{
private List<FileToCopy> _filesToCopy;

private static readonly string LogTitle = typeof (DllPackageFragmentInstaller).Name;
private static readonly string LogTitle = nameof(DllPackageFragmentInstaller);

/// <exclude />
public override IEnumerable<PackageFragmentValidationResult> Validate()
Expand Down Expand Up @@ -197,10 +197,11 @@ public override IEnumerable<XElement> Install()
this.InstallerContext.ZipFileSystem.WriteFileToDisk(fileToCopy.SourceFilename, tempFileName);

// Checking for dll version here:
var sourceAssemblyName = AssemblyName.GetAssemblyName(tempFileName);
var sourceAssemblyName = GetAssemblyNameWithErrorText(tempFileName, () => $"Source file name: '{fileToCopy.SourceFilename}'");

var sourceAssemblyVersion = sourceAssemblyName.Version;
var sourceFileVersion = GetDllFileVersion(tempFileName);

string targetDirectory = Path.GetDirectoryName(fileToCopy.TargetFilePath);
if (!Directory.Exists(targetDirectory))
{
Expand All @@ -213,10 +214,11 @@ public override IEnumerable<XElement> Install()

if (C1File.Exists(fileToCopy.TargetFilePath) && fileToCopy.Overwrite)
{
var existingAssemblyVersion = AssemblyName.GetAssemblyName(fileToCopy.TargetFilePath).Version;
var existingAssemblyName = GetAssemblyNameWithErrorText(fileToCopy.TargetFilePath, () => $"TargetFilePath: '{fileToCopy.TargetFilePath}' ");
var existingAssemblyVersion = existingAssemblyName.Version;
var existingFileVersion = GetDllFileVersion(fileToCopy.TargetFilePath);

if (existingAssemblyVersion == sourceAssemblyVersion
if (existingAssemblyVersion == sourceAssemblyVersion
&& existingFileVersion >= sourceFileVersion)
{
Log.LogInformation(LogTitle,
Expand Down Expand Up @@ -254,12 +256,11 @@ public override IEnumerable<XElement> Install()
Log.LogInformation(LogTitle, "Overwriting existing file '{0}' version '{2}', new version is '{1}'",
fileToCopy.TargetRelativeFilePath, sourceFileVersion, existingFileVersion);
}

if (addAssemblyBinding)
{
asmBindingsToAdd.Add(sourceAssemblyName);
}


File.Delete(fileToCopy.TargetFilePath);
File.Move(tempFileName, fileToCopy.TargetFilePath);
Expand All @@ -281,6 +282,18 @@ public override IEnumerable<XElement> Install()
yield return new XElement("Files", fileElements);
}

private AssemblyName GetAssemblyNameWithErrorText(string filePath, Func<string> getErrorText)
{
try
{
return AssemblyName.GetAssemblyName(filePath);
}
catch (Exception ex)
{
throw new InvalidOperationException("Failed to read AssemblyName from a DLL. " + getErrorText(), ex);
}
}

private Version GetDllFileVersion(string dllFilePath)
{
var fileVersionInfo = FileVersionInfo.GetVersionInfo(dllFilePath);
Expand Down Expand Up @@ -416,8 +429,8 @@ private string GetPublicKeyToken(AssemblyName assemblyName)
{
byte[] publicKeyTokenBytes = assemblyName.GetPublicKeyToken();

return publicKeyTokenBytes == null || publicKeyTokenBytes.Length == 0
? "null"
return publicKeyTokenBytes == null || publicKeyTokenBytes.Length == 0
? "null"
: string.Join("", publicKeyTokenBytes.Select(b => $"{b:x2}"));
}

Expand Down Expand Up @@ -474,6 +487,6 @@ public string OldVersion
}
}
}

}
}
6 changes: 1 addition & 5 deletions Composite/Core/Routing/MediaUrls.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System;
using System.Collections.Concurrent;
using System.Collections.Specialized;
using System.Management;
using System.Web;
using Composite.Core.Extensions;
using Composite.Core.WebClient;
Expand Down Expand Up @@ -268,9 +267,6 @@ private static string BuildPublicUrl(MediaUrlData mediaUrlData)
urlProvider = _defaultMediaUrlProvider.Value;
}




if (mediaUrlData.QueryParameters.Count > 0)
{
string mediaUrl;
Expand Down
Loading

0 comments on commit d051f94

Please sign in to comment.