26
26
import org .codehaus .plexus .i18n .I18N ;
27
27
import org .codehaus .plexus .util .StringUtils ;
28
28
29
+ import java .net .URI ;
29
30
import java .util .ArrayList ;
30
31
import java .util .Iterator ;
31
32
import java .util .List ;
@@ -169,7 +170,7 @@ public void renderBody()
169
170
170
171
if ( StringUtils .isNotEmpty ( mailingList .getSubscribe () ) )
171
172
{
172
- textRow .add ( createEmailLinkPatternedText ( subscribe , mailingList .getSubscribe (), null ) );
173
+ textRow .add ( createURILinkPatternedText ( subscribe , mailingList .getSubscribe (), null ) );
173
174
}
174
175
else
175
176
{
@@ -178,7 +179,7 @@ public void renderBody()
178
179
179
180
if ( StringUtils .isNotEmpty ( mailingList .getUnsubscribe () ) )
180
181
{
181
- textRow .add ( createEmailLinkPatternedText ( unsubscribe , mailingList .getUnsubscribe (), null ) );
182
+ textRow .add ( createURILinkPatternedText ( unsubscribe , mailingList .getUnsubscribe (), null ) );
182
183
}
183
184
else
184
185
{
@@ -187,7 +188,7 @@ public void renderBody()
187
188
188
189
if ( StringUtils .isNotEmpty ( mailingList .getPost () ) )
189
190
{
190
- textRow .add ( createEmailLinkPatternedText ( post , mailingList .getPost (), null ) );
191
+ textRow .add ( createURILinkPatternedText ( post , mailingList .getPost (), null ) );
191
192
}
192
193
else
193
194
{
@@ -262,23 +263,31 @@ public void renderBody()
262
263
}
263
264
264
265
/**
265
- * Create a link pattern text for email addresses defined by <code>{text, mailto:href}</code> . If href is null,
266
- * then <code>defaultHref</code> is used instead.
266
+ * Create a URI link pattern text for a mailing list . If no scheme is provided {@code mailto:}
267
+ * will be prepended by default. If href is null, then <code>defaultHref</code> is used instead.
267
268
*
268
269
* @param text a text.
269
- * @param href the email address to use.
270
+ * @param href the potential URI to use.
270
271
* @param defaultHref the String to use in case href is null.
271
- * @return an email link pattern.
272
+ * @return a link pattern.
272
273
* @see #createLinkPatternedText(String,String)
273
274
*/
274
- private String createEmailLinkPatternedText ( String text , String href , String defaultHref )
275
+ private String createURILinkPatternedText ( String text , String href , String defaultHref )
275
276
{
276
277
if ( href == null || href .isEmpty () )
277
278
{
278
279
return createLinkPatternedText ( text , defaultHref );
279
280
}
280
- return createLinkPatternedText ( text ,
281
- href .toLowerCase ( Locale .ENGLISH ).startsWith ( "mailto:" ) ? href : "mailto:" + href );
281
+
282
+ URI hrefUri = URI .create ( href );
283
+ if ( StringUtils .isNotEmpty ( hrefUri .getScheme () ) )
284
+ {
285
+ return createLinkPatternedText ( text , href );
286
+ }
287
+ else
288
+ {
289
+ return createLinkPatternedText ( text , "mailto:" + href );
290
+ }
282
291
}
283
292
}
284
293
}
0 commit comments