Skip to content

Commit 485c88e

Browse files
Merge branch '1.12.3'
2 parents 284df13 + 11f111b commit 485c88e

File tree

1,825 files changed

+508240
-158791
lines changed

Some content is hidden

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

1,825 files changed

+508240
-158791
lines changed

RockWeb/App_Code/BundleConfig.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@ public static void RegisterBundles( BundleCollection bundles )
3030
{
3131
// start with a clean bundles (this seems to have fixed the javascript errors that would occur on the first time you debug after opening the solution)
3232
bundles.ResetAll();
33-
33+
3434
bundles.Add( new ScriptBundle( "~/Scripts/Bundles/RockJQueryLatest" ).Include(
35-
"~/Scripts/jquery-3.3.1.min.js",
36-
"~/Scripts/jquery-migrate-3.0.0.min.js" ) );
35+
"~/Scripts/jquery-3.5.1.min.js",
36+
"~/Scripts/jquery-migrate-3.1.0.min.js" ) );
3737

38-
bundles.Add( new ScriptBundle( "~/bundles/WebFormsJs" ).Include(
38+
bundles.Add( new ScriptBundle( "~/Scripts/Bundles/WebFormsJs" ).Include(
39+
"~/Scripts/WebForms/MsAjax/MicrosoftAjax.js",
40+
"~/Scripts/WebForms/MsAjax/MicrosoftAjaxWebForms.js",
3941
"~/Scripts/WebForms/WebForms.js",
4042
"~/Scripts/WebForms/WebUIValidation.js",
4143
"~/Scripts/WebForms/MenuStandards.js",
@@ -46,7 +48,7 @@ public static void RegisterBundles( BundleCollection bundles )
4648
"~/Scripts/WebForms/WebParts.js" ) );
4749

4850
bundles.Add( new ScriptBundle( "~/Scripts/Bundles/RockLibs" ).Include(
49-
"~/Scripts/jquery-ui-1.10.4.custom.min.js",
51+
"~/Scripts/jquery-ui-1.12.1.custom.min.js",
5052
"~/Scripts/bootstrap.min.js",
5153
"~/Scripts/bootstrap-timepicker.js",
5254
"~/Scripts/bootstrap-datepicker.js",
@@ -60,7 +62,7 @@ public static void RegisterBundles( BundleCollection bundles )
6062
"~/Scripts/jquery.stickytableheaders.js",
6163
"~/Scripts/iscroll.js",
6264
"~/Scripts/jcrop.min.js",
63-
"~/Scripts/ResizeSensor.js",
65+
"~/Scripts/ResizeSensor.js",
6466
"~/Scripts/ion.rangeSlider/js/ion-rangeSlider/ion.rangeSlider.min.js",
6567
"~/Scripts/Rock/Extensions/*.js" ) );
6668

@@ -77,14 +79,19 @@ public static void RegisterBundles( BundleCollection bundles )
7779

7880
// Creating a separate "Admin" bundle specifically for JS functionality that needs
7981
// to be included for administrative users
80-
bundles.Add( new ScriptBundle( "~/Scripts/Bundles/RockAdmin" ).Include(
82+
bundles.Add( new ScriptBundle( "~/Scripts/Bundles/RockAdmin" ).Include(
8183
"~/Scripts/Rock/Admin/*.js" ) );
8284

8385
// Creating a separate "RockHtmlEditorPlugins" bundle specifically for JS functionality that needs
8486
// to be included for HtmlEditor
8587
bundles.Add( new ScriptBundle( "~/Scripts/Bundles/RockHtmlEditorPlugins" ).Include(
8688
"~/Scripts/summernote/plugins/*.js" ) );
8789

90+
// Creating a separate "StructureContentEditorPlugins" bundle specifically for JS functionality that needs
91+
// to be included for HtmlEditor
92+
bundles.Add( new ScriptBundle( "~/Scripts/Bundles/StructureContentEditorPlugins" ).Include(
93+
"~/Scripts/editor.js/*.js" ) );
94+
8895
// make sure the ConcatenationToken is what we want. This is supposed to be the default, but it occasionally was an empty string.
8996
foreach ( var bundle in bundles )
9097
{

RockWeb/App_Code/FileUploader.ashx.cs

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public virtual void ProcessRequest( HttpContext context )
5757
if ( !context.User.Identity.IsAuthenticated )
5858
{
5959
// If not, see if there's a valid token
60-
string authToken = context.Request.Headers["Authorization-Token"];
60+
string authToken = context.Request.Headers[Rock.Rest.HeaderTokens.AuthorizationToken];
6161
if ( string.IsNullOrWhiteSpace( authToken ) )
6262
{
6363
authToken = context.Request.Params["apikey"];
@@ -186,9 +186,17 @@ private void ProcessContentFile( HttpContext context, HttpPostedFile uploadedFil
186186
string untrustedFolderPath = context.Request.Form["folderPath"] ?? string.Empty;
187187
string encryptedRootFolder = context.Request.QueryString["rootFolder"];
188188

189-
/* Scrub the file name */
189+
// Scrub the file name
190190

191-
string scrubedFileName = ScrubFileName( untrustedFileName );
191+
/*
192+
3/17/2020 - JME
193+
And remove spaces, I did not add the removal of spaces to the scrub as the scrub logic
194+
has existed for a while and is used in other places that may not want that. We can move
195+
this to the scrub should we desire in the future.
196+
197+
Reason: The theme editor needs files with no spaces to be used in CSS
198+
*/
199+
string scrubedFileName = ScrubFileName( untrustedFileName ).Replace(" ", "_");
192200

193201
if ( string.IsNullOrWhiteSpace( scrubedFileName ) )
194202
{
@@ -287,7 +295,7 @@ private void ProcessContentFile( HttpContext context, HttpPostedFile uploadedFil
287295
/// <summary>
288296
/// Dictionary of deprecated or incorrect mime types and what they should be mapped to instead
289297
/// </summary>
290-
private Dictionary<string, string> _mimeTypeRemap = new Dictionary<string, string>
298+
private readonly Dictionary<string, string> _mimeTypeRemap = new Dictionary<string, string>
291299
{
292300
{ "text/directory", "text/vcard" },
293301
{ "text/directory; profile=vCard", "text/vcard" },
@@ -336,7 +344,18 @@ private void ProcessBinaryFile( HttpContext context, HttpPostedFile uploadedFile
336344
binaryFile.BinaryFileTypeId = binaryFileType.Id;
337345
binaryFile.MimeType = uploadedFile.ContentType;
338346
binaryFile.FileSize = uploadedFile.ContentLength;
339-
binaryFile.FileName = Path.GetFileName( uploadedFile.FileName );
347+
348+
/*
349+
* 2020-02-11 BJW
350+
*
351+
* The ReplaceSpecialCharacters extension call was added to remove characters that are outside the legal character range.
352+
* For example, if a file is moved from a Linux system, it might have a colon that manifests as a char with int value
353+
* in the thousands range (far outside typical character range. This causes unpredictable behavior with the various file
354+
* storage providers (GCP might handle it differently than the database storage provider). In order to add consistency
355+
* we simply replace any of these characters with an underscore. This includes spaces, which are normal, but are security
356+
* risks if they fall in certain parts of the filename.
357+
*/
358+
binaryFile.FileName = Path.GetFileName( uploadedFile.FileName.ReplaceSpecialCharacters( "_" ) );
340359

341360
if ( _mimeTypeRemap.ContainsKey( binaryFile.MimeType ) )
342361
{
@@ -413,7 +432,17 @@ public string ScrubFileName( string untrustedFileName )
413432
// Get the base filename
414433
string baseFileName = Path.GetFileName( untrustedFileName );
415434

416-
// Scrub invalid file characters
435+
/*
436+
* 2020-03-25 JME
437+
*
438+
* While C# has a listing of invalid file characters (used below), we added a few more of our own to help
439+
* with dealing with linking easily to files that have been uploaded.
440+
*
441+
* Specific Use Case: Theme Editor was having issues when using uploaded files from the Image Upload control
442+
*/
443+
baseFileName = baseFileName.Replace( "(", "" ).Replace( ")", "" );
444+
445+
// Scrub base invalid file characters
417446
return Regex.Replace( baseFileName, "[" + Regex.Escape( Path.GetInvalidFileNameChars().ToString() ) + "]", string.Empty, RegexOptions.CultureInvariant );
418447
}
419448

@@ -425,7 +454,7 @@ public string ScrubFileName( string untrustedFileName )
425454
public string ScrubFilePath( string untrustedFilePath )
426455
{
427456
// Scrub invalid path characters
428-
return Regex.Replace( untrustedFilePath, "[" + Regex.Escape( Path.GetInvalidPathChars().ToString() ) + "]", string.Empty, RegexOptions.CultureInvariant );
457+
return Regex.Replace( untrustedFilePath.Trim(), "[" + Regex.Escape( Path.GetInvalidPathChars().ToString() ) + "]", string.Empty, RegexOptions.CultureInvariant );
429458
}
430459
}
431460
}

RockWeb/App_Code/GetChannelFeed.cs

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
//
1717
using System;
1818
using System.Collections.Generic;
19+
using System.Data.Entity;
1920
using System.Linq;
2021
using System.Web;
2122
using Rock;
@@ -42,7 +43,16 @@ public void ProcessRequest( HttpContext context )
4243
request = context.Request;
4344
response = context.Response;
4445

45-
RockContext rockContext = new RockContext();
46+
string cacheKey = "Rock:GetChannelFeed:" + request.RawUrl;
47+
var contentCache = RockCache.Get( cacheKey );
48+
var mimeTypeCache = RockCache.Get( cacheKey + ":MimeType" );
49+
if ( mimeTypeCache != null && contentCache != null )
50+
{
51+
response.ContentType = ( string ) mimeTypeCache;
52+
response.Write( ( string ) contentCache );
53+
response.StatusCode = 200;
54+
return;
55+
}
4656

4757
if ( request.HttpMethod != "GET" && request.HttpMethod != "HEAD" )
4858
{
@@ -71,7 +81,7 @@ public void ProcessRequest( HttpContext context )
7181
return;
7282
}
7383

74-
ContentChannel channel = new ContentChannelService( rockContext ).Queryable( "ContentChannelType" ).FirstOrDefault( c => c.Id == channelId.Value );
84+
var channel = ContentChannelCache.Get( channelId.Value );
7585

7686
if ( channel == null )
7787
{
@@ -160,13 +170,17 @@ public void ProcessRequest( HttpContext context )
160170
}
161171

162172
// get channel items
173+
var rockContext = new RockContext();
163174
ContentChannelItemService contentService = new ContentChannelItemService( rockContext );
164175

165-
var content = contentService.Queryable( "ContentChannelType" )
166-
.Where( c =>
167-
c.ContentChannelId == channel.Id &&
168-
( c.Status == ContentChannelItemStatus.Approved || c.ContentChannel.ContentChannelType.DisableStatus || c.ContentChannel.RequiresApproval == false ) &&
169-
c.StartDateTime <= RockDateTime.Now );
176+
var content = contentService.Queryable().AsNoTracking().Where( c =>
177+
c.ContentChannelId == channel.Id &&
178+
c.StartDateTime <= RockDateTime.Now );
179+
180+
if ( !channel.ContentChannelType.DisableStatus && channel.RequiresApproval )
181+
{
182+
content = content.Where( cci => cci.Status == ContentChannelItemStatus.Approved );
183+
}
170184

171185
if ( channel.ContentChannelType.DateRangeType == ContentChannelDateType.DateRange )
172186
{
@@ -189,15 +203,15 @@ public void ProcessRequest( HttpContext context )
189203
content = content.OrderByDescending( c => c.StartDateTime );
190204
}
191205

192-
content = content.Take( rssItemLimit );
206+
var contentItems = content.Take( rssItemLimit ).ToList();
193207

194-
foreach ( var item in content )
208+
foreach ( var item in contentItems )
195209
{
196210
item.Content = item.Content.ResolveMergeFields( mergeFields );
197211

198212
// resolve any relative links
199213
var globalAttributes = GlobalAttributesCache.Get();
200-
string publicAppRoot = globalAttributes.GetValue( "PublicApplicationRoot" ).EnsureTrailingForwardslash();
214+
string publicAppRoot = globalAttributes.GetValue( "PublicApplicationRoot" );
201215
item.Content = item.Content.Replace( @" src=""/", @" src=""" + publicAppRoot );
202216
item.Content = item.Content.Replace( @" href=""/", @" href=""" + publicAppRoot );
203217

@@ -209,12 +223,23 @@ public void ProcessRequest( HttpContext context )
209223
}
210224
}
211225

212-
mergeFields.Add( "Items", content );
226+
mergeFields.Add( "Items", contentItems );
213227

214228
mergeFields.Add( "RockVersion", Rock.VersionInfo.VersionInfo.GetRockProductVersionNumber() );
215229

216-
response.Write( rssTemplate.ResolveMergeFields( mergeFields ) );
230+
var outputContent = rssTemplate.ResolveMergeFields( mergeFields );
231+
response.Write( outputContent );
217232

233+
var cacheDuration = dvRssTemplate.GetAttributeValue( "CacheDuration" ).AsInteger();
234+
if ( cacheDuration > 0 )
235+
{
236+
var expiration = RockDateTime.Now.AddMinutes( cacheDuration );
237+
if ( expiration > RockDateTime.Now )
238+
{
239+
RockCache.AddOrUpdate( cacheKey + ":MimeType", null, response.ContentType, expiration );
240+
RockCache.AddOrUpdate( cacheKey, null, outputContent, expiration );
241+
};
242+
}
218243
}
219244

220245
/// <summary>

RockWeb/App_Code/GetCommunication.ashx.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,11 @@ public bool IsReusable
5252
/// <param name="context">An <see cref="T:System.Web.HttpContext" /> object that provides references to the intrinsic server objects (for example, Request, Response, Session, and Server) used to service HTTP requests.</param>
5353
public void ProcessRequest( HttpContext context )
5454
{
55-
56-
int? communicationId = context.Request.QueryString["c"].AsIntegerOrNull();
57-
if ( communicationId.HasValue )
55+
Guid? communicationGuid = context.Request.QueryString["c"].AsGuidOrNull();
56+
if ( communicationGuid.HasValue )
5857
{
5958
var rockContext = new RockContext();
60-
var communication = new CommunicationService( rockContext ).Get( communicationId.Value );
59+
var communication = new CommunicationService( rockContext ).Get( communicationGuid.Value );
6160

6261
if ( communication != null )
6362
{
@@ -142,7 +141,7 @@ public void ProcessRequest( HttpContext context )
142141

143142
UAParser.ClientInfo client = UAParser.Parser.GetDefault().Parse( userAgent );
144143
var clientOs = client.OS.ToString();
145-
var clientBrowser = client.UserAgent.ToString();
144+
var clientBrowser = client.UA.ToString();
146145
var clientType = InteractionDeviceType.GetClientType( userAgent );
147146

148147
interactionService.AddInteraction( interactionComponent.Id, recipient.Id, "Opened", "", recipient.PersonAliasId, RockDateTime.Now, clientBrowser, clientOs, clientType, userAgent, ipAddress, null );

0 commit comments

Comments
 (0)