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;
4
4
5
5
public static partial class ContentScrubber
6
6
{
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
+
9
10
/// <summary>
10
11
/// Remove false security vulnerabilities from the content.
11
12
/// </summary>
@@ -22,9 +23,24 @@ public static partial class ContentScrubber
22
23
/// </remarks>
23
24
public static string ScrubContent ( this string content )
24
25
{
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 ;
26
39
}
27
40
28
41
[ GeneratedRegex ( """<a.+href="https:\/\/private-user-images\.githubusercontent\.com\/.+".+><\/a>""" ) ]
29
42
private static partial Regex ImageAnchorRegEx ( ) ;
43
+
44
+ [ GeneratedRegex ( """<a.+href="https:\/\/github\.com\/user-attachments\/assets\/.+".+><\/a>""" ) ]
45
+ private static partial Regex AttachmentAnchorRegEx ( ) ;
30
46
}
You can’t perform that action at this time.
0 commit comments