Skip to content

Commit e00038d

Browse files
committed
Merge branch 'v9/dev' into v9/feature/language-keys-cleanup
2 parents cef9003 + 4edf29e commit e00038d

File tree

180 files changed

+1843
-1392
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

180 files changed

+1843
-1392
lines changed

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# The MIT License (MIT) #
22

3-
Copyright (c) 2013-present Umbraco
3+
Copyright (c) 2005-present Umbraco
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
66

build/templates/UmbracoPackage/.template.config/template.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"version": {
2525
"type": "parameter",
2626
"datatype": "string",
27-
"defaultValue": "9.0.0-rc003",
27+
"defaultValue": "9.0.0-rc004",
2828
"description": "The version of Umbraco to load using NuGet",
2929
"replaces": "UMBRACO_VERSION_FROM_TEMPLATE"
3030
},

build/templates/UmbracoProject/.template.config/dotnetcli.host.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
"NoNodesViewPath":{
3333
"longName": "no-nodes-view-path",
3434
"shortName": ""
35+
},
36+
"UseHttpsRedirect": {
37+
"longName": "use-https-redirect",
38+
"shortName": ""
3539
}
3640
},
3741
"usageExamples": [

build/templates/UmbracoProject/.template.config/ide.host.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@
6262
"text": "Optional: Path to a custom view presented with the Umbraco installation contains no published content"
6363
},
6464
"isVisible": "true"
65+
},
66+
{
67+
"id": "UseHttpsRedirect",
68+
"name": {
69+
"text": "Optional: Adds code to Startup.cs to redirect HTTP to HTTPS and enables the UseHttps setting."
70+
},
71+
"isVisible": "true"
6572
}
6673
]
6774
}

build/templates/UmbracoProject/.template.config/template.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
"version": {
5858
"type": "parameter",
5959
"datatype": "string",
60-
"defaultValue": "9.0.0-rc003",
60+
"defaultValue": "9.0.0-rc004",
6161
"description": "The version of Umbraco to load using NuGet",
6262
"replaces": "UMBRACO_VERSION_FROM_TEMPLATE"
6363
},
@@ -293,6 +293,12 @@
293293
"UsingUnattenedInstall":{
294294
"type": "computed",
295295
"value": "(FriendlyName != \"\" && Email != \"\" && Password != \"\" && ConnectionString != \"\")"
296+
},
297+
"UseHttpsRedirect":{
298+
"type": "parameter",
299+
"datatype":"bool",
300+
"defaultValue": "false",
301+
"description": "Adds code to Startup.cs to redirect HTTP to HTTPS and enables the UseHttps setting (Default: false)"
296302
}
297303
}
298304
}

build/templates/UmbracoProject/appsettings.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,16 @@
1515
},
1616
"Umbraco": {
1717
"CMS": {
18-
//#if (HasNoNodesViewPath)
18+
//#if (HasNoNodesViewPath || UseHttpsRedirect)
1919
"Global": {
20+
//#if (!HasNoNodesViewPath && UseHttpsRedirect)
21+
"UseHttps": true
22+
//#elseif (UseHttpsRedirect)
23+
"UseHttps": true,
24+
//#endif
25+
//#if (HasNoNodesViewPath)
2026
"NoNodesViewPath": "NO_NODES_VIEW_PATH_FROM_TEMPLATE"
27+
//#endif
2128
},
2229
//#endif
2330
"Hosting": {

src/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<Version>9.0.0</Version>
44
<AssemblyVersion>9.0.0</AssemblyVersion>
5-
<InformationalVersion>9.0.0-rc003</InformationalVersion>
5+
<InformationalVersion>9.0.0-rc004</InformationalVersion>
66
<FileVersion>9.0.0</FileVersion>
77
<LangVersion Condition="'$(LangVersion)' == ''">9.0</LangVersion>
88
<NeutralLanguage>en-US</NeutralLanguage>

src/Umbraco.Core/Configuration/ConfigConnectionString.cs

Lines changed: 55 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,69 +5,88 @@ namespace Umbraco.Cms.Core.Configuration
55
{
66
public class ConfigConnectionString
77
{
8+
public string Name { get; }
9+
10+
public string ConnectionString { get; }
11+
12+
public string ProviderName { get; }
13+
814
public ConfigConnectionString(string name, string connectionString, string providerName = null)
915
{
1016
Name = name ?? throw new ArgumentNullException(nameof(name));
11-
ConnectionString = connectionString;
12-
13-
ProviderName = string.IsNullOrEmpty(providerName) ? ParseProvider(connectionString) : providerName;
17+
ConnectionString = ParseConnectionString(connectionString, ref providerName);
18+
ProviderName = providerName;
1419
}
1520

16-
public string ConnectionString { get; }
17-
public string ProviderName { get; }
18-
public string Name { get; }
19-
20-
private static bool IsSqlCe(DbConnectionStringBuilder builder) => (builder.TryGetValue("Data Source", out var ds)
21-
|| builder.TryGetValue("DataSource", out ds)) &&
22-
ds is string dataSource &&
23-
dataSource.EndsWith(".sdf");
21+
private static string ParseConnectionString(string connectionString, ref string providerName)
22+
{
23+
if (string.IsNullOrEmpty(connectionString))
24+
{
25+
return connectionString;
26+
}
2427

25-
private static bool IsSqlServer(DbConnectionStringBuilder builder) =>
26-
!string.IsNullOrEmpty(GetServer(builder)) &&
27-
((builder.TryGetValue("Database", out var db) && db is string database &&
28-
!string.IsNullOrEmpty(database)) ||
29-
(builder.TryGetValue("AttachDbFileName", out var a) && a is string attachDbFileName &&
30-
!string.IsNullOrEmpty(attachDbFileName)) ||
31-
(builder.TryGetValue("Initial Catalog", out var i) && i is string initialCatalog &&
32-
!string.IsNullOrEmpty(initialCatalog)));
28+
var builder = new DbConnectionStringBuilder
29+
{
30+
ConnectionString = connectionString
31+
};
3332

34-
private static string GetServer(DbConnectionStringBuilder builder)
35-
{
36-
if(builder.TryGetValue("Server", out var s) && s is string server)
33+
// Replace data directory placeholder
34+
const string attachDbFileNameKey = "AttachDbFileName";
35+
const string dataDirectoryPlaceholder = "|DataDirectory|";
36+
if (builder.TryGetValue(attachDbFileNameKey, out var attachDbFileNameValue) &&
37+
attachDbFileNameValue is string attachDbFileName &&
38+
attachDbFileName.Contains(dataDirectoryPlaceholder))
3739
{
38-
return server;
40+
var dataDirectory = AppDomain.CurrentDomain.GetData("DataDirectory")?.ToString();
41+
if (!string.IsNullOrEmpty(dataDirectory))
42+
{
43+
builder[attachDbFileNameKey] = attachDbFileName.Replace(dataDirectoryPlaceholder, dataDirectory);
44+
45+
// Mutate the existing connection string (note: the builder also lowercases the properties)
46+
connectionString = builder.ToString();
47+
}
3948
}
4049

41-
if ((builder.TryGetValue("Data Source", out var ds)
42-
|| builder.TryGetValue("DataSource", out ds)) && ds is string dataSource)
50+
// Also parse provider name now we already have a builder
51+
if (string.IsNullOrEmpty(providerName))
4352
{
44-
return dataSource;
53+
providerName = ParseProviderName(builder);
4554
}
4655

47-
return "";
56+
return connectionString;
4857
}
4958

50-
private static string ParseProvider(string connectionString)
59+
/// <summary>
60+
/// Parses the connection string to get the provider name.
61+
/// </summary>
62+
/// <param name="connectionString">The connection string.</param>
63+
/// <returns>
64+
/// The provider name or <c>null</c> is the connection string is empty.
65+
/// </returns>
66+
public static string ParseProviderName(string connectionString)
5167
{
5268
if (string.IsNullOrEmpty(connectionString))
5369
{
5470
return null;
5571
}
5672

57-
var builder = new DbConnectionStringBuilder {ConnectionString = connectionString};
58-
if (IsSqlCe(builder))
73+
var builder = new DbConnectionStringBuilder
5974
{
60-
return Constants.DbProviderNames.SqlCe;
61-
}
75+
ConnectionString = connectionString
76+
};
6277

78+
return ParseProviderName(builder);
79+
}
6380

64-
if (IsSqlServer(builder))
81+
private static string ParseProviderName(DbConnectionStringBuilder builder)
82+
{
83+
if ((builder.TryGetValue("Data Source", out var dataSource) || builder.TryGetValue("DataSource", out dataSource)) &&
84+
dataSource?.ToString().EndsWith(".sdf", StringComparison.OrdinalIgnoreCase) == true)
6585
{
66-
return Constants.DbProviderNames.SqlServer;
86+
return Constants.DbProviderNames.SqlCe;
6787
}
6888

69-
throw new ArgumentException("Cannot determine provider name from connection string",
70-
nameof(connectionString));
89+
return Constants.DbProviderNames.SqlServer;
7190
}
7291
}
7392
}

src/Umbraco.Core/Configuration/Models/ConnectionStrings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ private string umbracoDbDSN
2626
/// <summary>
2727
/// Gets or sets a value for the Umbraco database connection string..
2828
/// </summary>
29-
public ConfigConnectionString UmbracoConnectionString { get; set; }
29+
public ConfigConnectionString UmbracoConnectionString { get; set; } = new ConfigConnectionString(Constants.System.UmbracoConnectionName, null);
3030
}
3131
}

src/Umbraco.Core/Configuration/Models/RuntimeSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class RuntimeSettings
1515
public int? MaxQueryStringLength { get; set; }
1616

1717
/// <summary>
18-
/// Gets or sets a value for the maximum request length.
18+
/// Gets or sets a value for the maximum request length in kb.
1919
/// </summary>
2020
public int? MaxRequestLength { get; set; }
2121
}

0 commit comments

Comments
 (0)