Skip to content

Commit 739d681

Browse files
authored
Merge branch 'master' into master
2 parents bdbe49e + 7f695b4 commit 739d681

File tree

190 files changed

+7677
-3784
lines changed

Some content is hidden

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

190 files changed

+7677
-3784
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,5 @@ BlogEngine/.vs/
186186

187187
# Default extensions data
188188
BlogEngine/BlogEngine.NET/App_Data/datastore/extensions/*.xml
189+
/.vs/slnx.sqlite
190+
/.vs/BlogEngine.NET/config/applicationhost.config

BlogEngine/BlogEngine.Core/API/MetaWeblog/XMLRPCRequest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ private static MWAPost GetPost(XmlNode node)
327327
/// </param>
328328
private void LoadXmlRequest(string xml)
329329
{
330-
var request = new XmlDocument();
330+
var request = new XmlDocument() { XmlResolver = null };
331331
try
332332
{
333333
if (!(xml.StartsWith("<?xml") || xml.StartsWith("<method")))
@@ -505,4 +505,4 @@ private static string ParseRequest(HttpContext context)
505505

506506
#endregion
507507
}
508-
}
508+
}

BlogEngine/BlogEngine.Core/BlogSettings.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -420,27 +420,27 @@ public string Theme
420420
var request = context.Request;
421421
if (request.QueryString["theme"] != null)
422422
{
423-
return request.QueryString["theme"];
423+
return request.QueryString["theme"].SanitizePath();
424424
}
425425

426426
var cookie = request.Cookies[this.ThemeCookieName];
427427
if (cookie != null)
428428
{
429-
return cookie.Value;
429+
return cookie.Value.SanitizePath();
430430
}
431431

432432
if (Utils.ShouldForceMainTheme(request))
433433
{
434-
return this.configuredTheme;
434+
return this.configuredTheme.SanitizePath();
435435
}
436436
}
437437

438-
return this.configuredTheme;
438+
return this.configuredTheme.SanitizePath();
439439
}
440440

441441
set
442442
{
443-
this.configuredTheme = String.IsNullOrEmpty(value) ? String.Empty : value;
443+
this.configuredTheme = String.IsNullOrEmpty(value) ? String.Empty : value.SanitizePath();
444444
}
445445
}
446446

BlogEngine/BlogEngine.Core/Data/FileManagerRepository.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ public IEnumerable<FileInstance> Find(int take = 10, int skip = 0, string path =
1818
var rwr = Utils.RelativeWebRoot;
1919
var responsePath = "root";
2020

21+
path = path.SanitizePath();
22+
2123
if(string.IsNullOrEmpty(path))
2224
path = Blog.CurrentInstance.StorageLocation + Utils.FilesFolder;
2325

BlogEngine/BlogEngine.Core/Data/Models/SelectOption.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ public class SelectOption
1414
/// </summary>
1515
public string OptionValue { get; set; }
1616
/// <summary>
17+
/// Option Summary
18+
/// </summary>
19+
public string OptionSummary { get; set; }
20+
/// <summary>
1721
/// Is option selected
1822
/// </summary>
1923
public bool IsSelected { get; set; }

BlogEngine/BlogEngine.Core/Extensions.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,27 @@ public static bool TryParse<T>(this string theString, out T output)
9292

9393
return success;
9494
}
95+
96+
/// <summary>
97+
/// Sanitize path by removing invalid characters. Valid path should look similar to "path/to/sub/folder"
98+
/// </summary>
99+
/// <param name="str">String to sanitize</param>
100+
/// <param name="root">Optionally validate datastore root</param>
101+
/// <returns>String out</returns>
102+
public static string SanitizePath(this string str, string root = "")
103+
{
104+
if (str.Contains(".."))
105+
return "";
106+
107+
if (str.StartsWith("~/") && !string.IsNullOrEmpty(root) && !str.StartsWith(root))
108+
return "";
109+
110+
str = str.Replace(".", "").Replace("\\", "").Replace("%2F", "");
111+
112+
if (str.Contains("//"))
113+
return "";
114+
115+
return str;
116+
}
95117
}
96118
}

BlogEngine/BlogEngine.Core/Properties/AssemblyInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
[assembly: AssemblyConfiguration("")]
1414
[assembly: AssemblyCompany("")]
1515
[assembly: AssemblyProduct("BlogEngine.NET")]
16-
[assembly: AssemblyCopyright("Copyright @ 2007-2017")]
16+
[assembly: AssemblyCopyright("Copyright @ 2007-2019")]
1717
[assembly: AssemblyTrademark("")]
1818
[assembly: AssemblyCulture("")]
1919
[assembly: CLSCompliant(false)]
2020
[assembly: ComVisible(false)]
2121
[assembly: AllowPartiallyTrustedCallers]
22-
[assembly: AssemblyVersion("3.3.6.0")]
23-
[assembly: SecurityRules(SecurityRuleSet.Level1)]
22+
[assembly: AssemblyVersion("3.3.8.0")]
23+
[assembly: SecurityRules(SecurityRuleSet.Level1)]

BlogEngine/BlogEngine.Core/Services/Security/Security.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,7 @@ public static bool AuthenticateUser(string username, string password, bool remem
185185
string returnUrl = context.Request.QueryString["returnUrl"];
186186

187187
// ignore Return URLs not beginning with a forward slash, such as remote sites.
188-
if (string.IsNullOrWhiteSpace(returnUrl) || !returnUrl.StartsWith("/"))
189-
returnUrl = null;
190-
191-
if (!string.IsNullOrWhiteSpace(returnUrl))
188+
if (Security.IsLocalUrl(returnUrl))
192189
{
193190
context.Response.Redirect(returnUrl);
194191
}
@@ -204,6 +201,19 @@ public static bool AuthenticateUser(string username, string password, bool remem
204201
return false;
205202
}
206203

204+
private static bool IsLocalUrl(string url)
205+
{
206+
if (string.IsNullOrWhiteSpace(url))
207+
{
208+
return false;
209+
}
210+
else
211+
{
212+
return ((url[0] == '/' && (url.Length == 1 || (url[1] != '/' && url[1] != '\\'))) || // "/" or "/foo" but not "//" or "/\"
213+
(url.Length > 1 && url[0] == '~' && url[1] == '/')); // "~/" or "~/foo"
214+
}
215+
}
216+
207217
private const string AUTH_TKT_USERDATA_DELIMITER = "-|-";
208218

209219
private static string SecurityValidationKey

BlogEngine/BlogEngine.Core/Services/Syndication/SyndicationGenerator.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class SyndicationGenerator
3535
/// <summary>
3636
/// Private member to hold the URI of the syndication generation utility.
3737
/// </summary>
38-
private static readonly Uri GeneratorUri = new Uri("http://dotnetblogengine.net/");
38+
private static readonly Uri GeneratorUri = new Uri("https://blogengine.io/");
3939

4040
/// <summary>
4141
/// Private member to hold the version of the syndication generation utility.
@@ -135,7 +135,7 @@ public static Dictionary<string, string> SupportedNamespaces
135135
{ "wfw", "http://wellformedweb.org/CommentAPI/" },
136136
{ "slash", "http://purl.org/rss/1.0/modules/slash/" },
137137
{ "geo", "http://www.w3.org/2003/01/geo/wgs84_pos#" },
138-
{ "betag", "http://dotnetblogengine.net/schemas/tags"}
138+
{ "betag", "https://blogengine.io/schemas/tags"}
139139
});
140140
}
141141
}
@@ -536,7 +536,7 @@ private static void WriteAtomEntry(XmlWriter writer, IPublishable publishable)
536536
{
537537
foreach (var tag in publishable.Tags)
538538
{
539-
writer.WriteElementString("betag", "tag", "http://dotnetblogengine.net/schemas/tags", tag);
539+
writer.WriteElementString("betag", "tag", "https://blogengine.io/schemas/tags", tag);
540540
}
541541
}
542542

@@ -725,7 +725,7 @@ private static void WriteRssItem(XmlWriter writer, IPublishable publishable)
725725
{
726726
foreach (var tag in publishable.Tags)
727727
{
728-
writer.WriteElementString("betag", "tag", "http://dotnetblogengine.net/schemas/tags", tag);
728+
writer.WriteElementString("betag", "tag", "https://blogengine.io/schemas/tags", tag);
729729
}
730730
}
731731

BlogEngine/BlogEngine.Core/Web/HttpHandlers/PingbackHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ private static XmlDocument RetrieveXmlDocument(HttpContext context)
337337
context.Response.End();
338338
}
339339

340-
var doc = new XmlDocument();
340+
var doc = new XmlDocument() { XmlResolver = null };
341341
doc.LoadXml(xml);
342342
return doc;
343343
}
@@ -432,4 +432,4 @@ private void ExamineSourcePage(string sourceUrl, string targetUrl)
432432

433433
#endregion
434434
}
435-
}
435+
}

0 commit comments

Comments
 (0)