@@ -565,11 +565,19 @@ private void CorrectImagePath(WorkItem wi, WiItem wiItem, WiRevision rev, ref st
565565 throw new ArgumentException ( nameof ( rev ) ) ;
566566 }
567567
568- foreach ( var att in wiItem . Revisions . SelectMany ( r => r . Attachments . Where ( a => a . Change == ReferenceChangeType . Added ) ) )
569- {
570- var fileName = att . FilePath . Split ( '\\ ' ) ? . Last ( ) ?? string . Empty ;
571- var encodedFileName = HttpUtility . UrlEncode ( fileName ) ;
572- if ( textField . Contains ( fileName ) || textField . IndexOf ( encodedFileName , StringComparison . OrdinalIgnoreCase ) >= 0 || textField . Contains ( "_thumb_" + att . AttOriginId ) )
568+ var filteredRelations = wiItem . Revisions . SelectMany ( r => r . Attachments . Where ( a => a . Change == ReferenceChangeType . Added ) ) ;
569+
570+ foreach ( var att in filteredRelations )
571+ {
572+ string fileName = att . FilePath . Split ( '\\ ' ) ? . Last ( ) ?? string . Empty ;
573+ string encodedFileName = EncodeFileNameUsingJiraStandard ( fileName ) ;
574+ string restApiUrlOption = "/rest/api/3/attachment/content/" + att . AttOriginId ;
575+ if (
576+ textField . Contains ( fileName )
577+ || textField . IndexOf ( encodedFileName , StringComparison . OrdinalIgnoreCase ) >= 0
578+ || textField . Contains ( "_thumb_" + att . AttOriginId )
579+ || textField . Contains ( restApiUrlOption )
580+ )
573581 {
574582 var tfsAtt = IdentifyAttachment ( att , wi , isAttachmentMigratedDelegate ) ;
575583
@@ -596,6 +604,15 @@ private void CorrectImagePath(WorkItem wi, WiItem wiItem, WiRevision rev, ref st
596604 }
597605 }
598606
607+ public string EncodeFileNameUsingJiraStandard ( string fileName )
608+ {
609+ string fileNameEncoded = HttpUtility . UrlEncode ( fileName ) ;
610+ fileNameEncoded = fileNameEncoded . Replace ( "(" , "%28" ) ;
611+ fileNameEncoded = fileNameEncoded . Replace ( ")" , "%29" ) ;
612+ return fileNameEncoded ;
613+ }
614+
615+
599616 private void CorrectClosedByAndClosedDate ( WiRevision rev , WorkItem wi )
600617 {
601618 var wiState = wi . Fields [ WiFieldReference . State ] . ToString ( ) ?? string . Empty ;
0 commit comments