mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-11-24 08:46:48 +08:00
Optimizing image tag regex
This commit is contained in:
@@ -22,6 +22,7 @@ namespace Orchard.MediaProcessing.Filters {
|
|||||||
private readonly IImageProfileManager _profileManager;
|
private readonly IImageProfileManager _profileManager;
|
||||||
|
|
||||||
private MediaHtmlFilterSettingsPart _settingsPart;
|
private MediaHtmlFilterSettingsPart _settingsPart;
|
||||||
|
private static readonly Regex _imageTagRegex = new Regex(@"<img\b[^>]*>", RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||||
private static readonly Dictionary<string, string> _validExtensions = new Dictionary<string, string> {
|
private static readonly Dictionary<string, string> _validExtensions = new Dictionary<string, string> {
|
||||||
{ ".jpeg", "jpg" }, // For example: .jpeg supports compression (quality), format to 'jpg'.
|
{ ".jpeg", "jpg" }, // For example: .jpeg supports compression (quality), format to 'jpg'.
|
||||||
{ ".jpg", "jpg" },
|
{ ".jpg", "jpg" },
|
||||||
@@ -52,7 +53,7 @@ namespace Orchard.MediaProcessing.Filters {
|
|||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
var matches = Regex.Matches(text, @"<img\b[^>]*>");
|
var matches = _imageTagRegex.Matches(text);
|
||||||
|
|
||||||
if (matches.Count == 0) {
|
if (matches.Count == 0) {
|
||||||
return text;
|
return text;
|
||||||
|
|||||||
Reference in New Issue
Block a user