File tree Expand file tree Collapse file tree 1 file changed +19
-3
lines changed
Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -4,8 +4,9 @@ namespace DotNet.DocsTools.Utility;
44
55public static partial class ContentScrubber
66{
7- private const string Replacement = "<i>Image link removed to protect against security vulnerability.</i>" ;
8-
7+ private const string ImgReplacement = "<i>Image link removed to protect against security vulnerability.</i>" ;
8+ private const string UserAssetReplacement = "<i>User asset removed to protect against security vulnerability.</i>" ;
9+
910 /// <summary>
1011 /// Remove false security vulnerabilities from the content.
1112 /// </summary>
@@ -22,9 +23,24 @@ public static partial class ContentScrubber
2223 /// </remarks>
2324 public static string ScrubContent ( this string content )
2425 {
25- return ImageAnchorRegEx ( ) . Replace ( content , Replacement ) ;
26+ var postImageReplacementContent = ImageAnchorRegEx ( ) . Replace ( content , ImgReplacement ) ;
27+ if ( content != postImageReplacementContent )
28+ {
29+ Console . WriteLine ( "Replaced linked image in content." ) ;
30+ }
31+
32+ var postUserAttachementReplacementContent = AttachmentAnchorRegEx ( ) . Replace ( postImageReplacementContent , UserAssetReplacement ) ;
33+ if ( postImageReplacementContent != postUserAttachementReplacementContent )
34+ {
35+ Console . WriteLine ( "Replaced linked user asset in content." ) ;
36+ }
37+
38+ return postUserAttachementReplacementContent ;
2639 }
2740
2841 [ GeneratedRegex ( """<a.+href="https:\/\/private-user-images\.githubusercontent\.com\/.+".+><\/a>""" ) ]
2942 private static partial Regex ImageAnchorRegEx ( ) ;
43+
44+ [ GeneratedRegex ( """<a.+href="https:\/\/github\.com\/user-attachments\/assets\/.+".+><\/a>""" ) ]
45+ private static partial Regex AttachmentAnchorRegEx ( ) ;
3046}
You can’t perform that action at this time.
0 commit comments