Skip to content

Commit

Permalink
Merge tag 'v1.9.10' into dnn
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/ClientDependency.Core/CssHelper.cs
  • Loading branch information
bdukes committed Aug 11, 2021
2 parents f3e7f19 + 4fd3091 commit 133fe7c
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# These are supported funding model platforms

github: github: [shazwazza]
github: [shazwazza]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Build status](https://ci.appveyor.com/api/projects/status/qx991ywaat8r8a2r?svg=true)](https://ci.appveyor.com/project/Shandem/clientdependency)

![ClientDependency Framework](ClientDependencyLogo.png?raw=true)
![ClientDependency Framework](assets/ClientDependencyLogo.png?raw=true)

---
_❤️ If you use and like CDF please consider [becoming a GitHub Sponsor](https://github.com/sponsors/Shazwazza/) ❤️_
Expand Down
2 changes: 1 addition & 1 deletion build/ClientDependency-Less.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<copyright>Copyright © Shannon Deminick $copyrightyear$</copyright>
<repository type="git" url="https://github.com/Shandem/ClientDependency" />
<dependencies>
<dependency id="dotless" version="1.5" />
<dependency id="dotless" version="[1.5.2]" />
<dependency id="ClientDependency" version="1.8" />
</dependencies>
</metadata>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace ClientDependency.Core.CompositeFiles
public class CompositeFileMap
{

internal CompositeFileMap(string key, string compressionType, string file, IEnumerable<string> filePaths, int version)
public CompositeFileMap(string key, string compressionType, string file, IEnumerable<string> filePaths, int version)
{
DependentFiles = filePaths;
FileKey = key;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,19 +210,32 @@ public CompositeFileDefinition WritePathToStream(ClientDependencyType type, stri
//Before we try to load it by URI, we want to check if the URI is a local file request.
//We can try to detect if it is and try to load it from the file system.
//If the file isn't local and doesn't exist then we'll continue trying to load it via the URI.

//NOTE: At this stage we've already validated that the file type is based on the file types registered with CDF.
if (Uri.TryCreate(path, UriKind.RelativeOrAbsolute, out Uri uri)
&& uri.IsLocalUri(context)
//extract the path/query of the request and ensure it starts with the virtual path marker (~/) so that the file
//can only be looked up local to this website.
&& PathHelper.TryGetFileInfo(uri.PathAndQuery.EnsureStartsWith("/").EnsureStartsWith("~"), context, out var fi))
{
def = WriteFileToStream(sw, fi, type, path, context);
}
else

if (Uri.TryCreate(path, UriKind.RelativeOrAbsolute, out Uri uri))
{
//external request to a file based dependency
def = WriteFileToStream(sw, path, type, context);
if (uri.IsLocalUri(context))
{
//extract the path of the request and ensure it starts with the virtual path marker (~/) so that the file
//can only be looked up local to this website.
var absPath = uri.AbsolutePath.EnsureStartsWith("/").EnsureStartsWith("~");

if (PathHelper.TryGetFileInfo(absPath, context, out var fi))
{
//Re-validate the extension since URIs and file names can parse differently
extension = fi.Extension;
if (fileBasedExtensions.Contains(extension, StringComparer.InvariantCultureIgnoreCase))
{
def = WriteFileToStream(sw, fi, type, path, context);
}
}
}
else
{
//external request to a file based dependency
def = WriteFileToStream(sw, path, type, context);
}
}
}
}
Expand Down Expand Up @@ -275,6 +288,13 @@ protected virtual CompositeFileDefinition WriteFileToStream(StreamWriter sw, str
/// <param name="http"></param>
protected virtual CompositeFileDefinition WriteFileToStream(StreamWriter sw, FileInfo fi, ClientDependencyType type, string origUrl, HttpContextBase http)
{
if (fi is null) throw new ArgumentNullException(nameof(fi));

if (!PathHelper.TryGetFileExtension(origUrl, out var ext1))
throw new InvalidOperationException($"Could not get extension from file name {origUrl}");
if (!fi.Extension.Equals(ext1, StringComparison.InvariantCultureIgnoreCase))
throw new InvalidOperationException("The file extensions for the resolved file and the original URL do not match");

//get a writer for the file, first check if there's a specific file writer
//then check for an extension writer.
var writer = FileWriters.GetWriterForFile(origUrl);
Expand Down
2 changes: 1 addition & 1 deletion src/ClientDependency.Core/CssHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace ClientDependency.Core
{
public static class CssHelper
{
private static readonly Regex ImportCssRegex = new Regex(@"@import url\((.+?)\)\s*?;?", RegexOptions.Compiled);
private static readonly Regex ImportCssRegex = new Regex(@"@import url\((.+?)\)\s*;?", RegexOptions.Compiled);
private static readonly Regex CssUrlRegex = new Regex(@"url\(((?![""']?data:|[""']?#).+?)\)", RegexOptions.Compiled);

/// <summary>
Expand Down
8 changes: 5 additions & 3 deletions src/ClientDependency.Core/RequestHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@ internal static bool TryReadUri(
//otherwise change it to an absolute path and try to request it.
if (!uri.IsAbsoluteUri)
{
var domainPathQuery = uri.GetLeftPart(UriPartial.Query);

//if this is an ASPX page, we should execute it instead of http getting it.
if (uri.ToString().EndsWith(".aspx", StringComparison.InvariantCultureIgnoreCase))
if (domainPathQuery.EndsWith(".aspx", StringComparison.InvariantCultureIgnoreCase))
{
var sw = new StringWriter();
try
{
http.Server.Execute(url, sw);
http.Server.Execute(domainPathQuery, sw);
requestContents = sw.ToString();
sw.Close();
resultUri = uri;
Expand All @@ -72,7 +74,7 @@ internal static bool TryReadUri(
}

//if this is a call for a web resource, we should http get it
if (url.StartsWith(http.Request.ApplicationPath.TrimEnd('/') + "/webresource.axd", StringComparison.InvariantCultureIgnoreCase))
if (domainPathQuery.StartsWith(http.Request.ApplicationPath.TrimEnd('/') + "/webresource.axd", StringComparison.InvariantCultureIgnoreCase))
{
bundleExternalUri = true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ClientDependency.Less/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="dotless" version="1.5.0" targetFramework="net40" />
<package id="dotless" version="1.5.2" targetFramework="net40" />
<package id="Microsoft.Build.Tasks.Git" version="1.0.0-beta2-18618-05" targetFramework="net40" developmentDependency="true" />
<package id="Microsoft.SourceLink.Common" version="1.0.0-beta2-18618-05" targetFramework="net40" developmentDependency="true" />
<package id="Microsoft.SourceLink.GitHub" version="1.0.0-beta2-18618-05" targetFramework="net40" developmentDependency="true" />
Expand Down
2 changes: 1 addition & 1 deletion src/ClientDependency.UnitTests/CssImportStatementsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void Retain_External_Imports_From_Stream()
public void Can_Parse_Import_Statements()
{
var css = @"@import url('/css/typography.css');
@import url('/css/layout.css');
@import url('/css/layout.css') ;
@import url('http://mysite/css/color.css');
@import url(/css/blah.css);
Expand Down
2 changes: 1 addition & 1 deletion src/ClientDependency.Web.Test/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="dotless" version="1.5.0" targetFramework="net45" />
<package id="dotless" version="1.5.2" targetFramework="net45" />
<package id="IronRuby" version="1.1.3" targetFramework="net40" />
<package id="Microsoft.AspNet.Mvc" version="5.0.0" targetFramework="net45" />
<package id="Microsoft.AspNet.Razor" version="3.0.0" targetFramework="net45" />
Expand Down
6 changes: 3 additions & 3 deletions src/SolutionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
[assembly: AssemblyCulture("")]


[assembly: AssemblyVersion("1.9.8")]
[assembly: AssemblyFileVersion("1.9.8")]
[assembly: AssemblyInformationalVersion("1.9.8")]
[assembly: AssemblyVersion("1.9.9")]
[assembly: AssemblyFileVersion("1.9.9")]
[assembly: AssemblyInformationalVersion("1.9.9")]

0 comments on commit 133fe7c

Please sign in to comment.