File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -381,13 +381,28 @@ private static String readStream(java.io.InputStream stream) throws IOException
381381 }
382382
383383 private static AttachmentReplacement replaceAttachments (String body , Map <String , String > urls ) {
384+ // Build a case-insensitive lookup alongside the original map
385+ Map <String , String > urlsCI = new HashMap <>();
386+ for (Map .Entry <String , String > e : urls .entrySet ()) {
387+ if (e .getKey () != null && e .getValue () != null ) {
388+ urlsCI .put (e .getKey ().toLowerCase (), e .getValue ());
389+ }
390+ }
391+
384392 Pattern pattern = Pattern .compile ("\\ (attachment:([^\\ )]+)\\ )" );
385393 Matcher matcher = pattern .matcher (body );
386394 StringBuffer sb = new StringBuffer ();
387395 List <String > missing = new ArrayList <>();
388396 while (matcher .find ()) {
389397 String name = matcher .group (1 );
398+ if (name != null ) {
399+ name = name .trim ();
400+ }
390401 String url = urls .get (name );
402+ if (url == null && name != null ) {
403+ // try case-insensitive match
404+ url = urlsCI .get (name .toLowerCase ());
405+ }
391406 if (url != null ) {
392407 matcher .appendReplacement (sb , Matcher .quoteReplacement ("(" + url + ")" ));
393408 } else {
You can’t perform that action at this time.
0 commit comments