Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,10 @@ static String[] extractJavadocExamples(String javadoc) {
}

private static int determineJavadocLengthUntilExamples(String javadoc, boolean includeExamplesTextLength) {
final Pattern PATTERN_EXAMPLES_MARKER = compile("(?i)(?s).*(?<examples> examples?:\\s*)"); // https://regex101.com/r/UMMmlV/3
final Pattern PATTERN_EXAMPLES_MARKER = compile("(?i)(?s).*( examples?:\\s*)"); // https://regex101.com/r/UMMmlV/3
final Matcher matcher = PATTERN_EXAMPLES_MARKER.matcher(javadoc);
return (matcher.find())
? matcher.end() - (!includeExamplesTextLength ? matcher.group("examples").length() : 0)
? matcher.end() - (!includeExamplesTextLength ? matcher.group(3).length() : 0)
: javadoc.length();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,10 @@ public static List<String> getJavadocSeeAlsoReferences(Method m, boolean onlyInc
// add padding for readability
if (longestLink > 0) {
for (int i = 0; i < seeAlsoReferences.size(); i++) {
Matcher matcher = compile("\\[\\[(?<link>.+?)]](?<description>.*)").matcher(seeAlsoReferences.get(i));
Matcher matcher = compile("\\[\\[(.+?)]](.*)").matcher(seeAlsoReferences.get(i));
if (matcher.find()) {
String newlineFixer = seeAlsoReferences.size() > 1 && allDescriptionsOnNextLine ? "\n\t" : "";
String paddedReplacement = padRight(matcher.group("link"), longestLink) + newlineFixer + matcher.group("description");
String paddedReplacement = padRight(matcher.group(1), longestLink) + newlineFixer + matcher.group(2);
seeAlsoReferences.set(i, matcher.replaceFirst(paddedReplacement));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public interface EmailPopulatingBuilder {
* Regular Expression to find all {@code <img src="...">} entries in an HTML document.It needs to cater for various things, like more whitespaces including newlines on any place, HTML is not case
* sensitive and there can be arbitrary text between "IMG" and "SRC" like IDs and other things.
*/
Pattern IMG_SRC_PATTERN = compile("(?<imageTagStart><[Ii][Mm][Gg]\\s*[^>]*?\\s+[Ss][Rr][Cc]\\s*=\\s*[\"'])(?<src>[^\"']+?)(?<imageSrcEnd>[\"'])");
Pattern IMG_SRC_PATTERN = compile("(<[Ii][Mm][Gg]\\s*[^>]*?\\s+[Ss][Rr][Cc]\\s*=\\s*[\"'])([^\"']+?)([\"'])");

/**
* Validated DKIM values and then delegates to {@link Email#Email(EmailPopulatingBuilder)} with <code>this</code> as argument.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public final class ConfigLoader {
/**
* This pattern recognizes extra property lines that should be loaded directly into JavaMail on the Session object.
*/
private static final Pattern EXTRA_PROPERTY_PATTERN = compile("^simplejavamail\\.extraproperties\\.(?<actualProperty>.*)");
private static final Pattern EXTRA_PROPERTY_PATTERN = compile("^simplejavamail\\.extraproperties\\.(.*)");

/**
* Initially try to load properties from "{@value #DEFAULT_CONFIG_FILENAME}".
Expand Down Expand Up @@ -407,7 +407,7 @@ private static Map<String, String> filterExtraJavaMailProperties(@Nullable final
final Matcher matcher = EXTRA_PROPERTY_PATTERN.matcher((String) propertyKey.getKey());
if (matcher.matches()) {
assumeTrue(propertyKey.getValue() instanceof String, "Simple Java Mail property value can only be of type String");
extraProperties.put(matcher.group("actualProperty"), (String) propertyKey.getValue());
extraProperties.put(matcher.group(1), (String) propertyKey.getValue());
if (filePropertiesLeft != null) {
filePropertiesLeft.remove(propertyKey.getKey());
}
Expand Down Expand Up @@ -457,4 +457,4 @@ static Object parsePropertyValue(final @Nullable String propertyValue) {
// return value as is (which should be string)
return propertyValue;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ private void resolveDynamicEmbeddedImageDataSources() {

final Matcher matcher = IMG_SRC_PATTERN.matcher(this.textHTML);
while (matcher.find()) {
final String srcLocation = matcher.group("src");
final String srcLocation = matcher.group(2);
if (!srcLocation.startsWith("cid:")) {
if (!generatedCids.containsKey(srcLocation)) {
final DataSource dataSource = resolveDynamicEmbeddedImageDataSource(srcLocation);
Expand All @@ -435,7 +435,7 @@ private void resolveDynamicEmbeddedImageDataSources() {
}
}
if (generatedCids.containsKey(srcLocation)) {
final String imgSrcReplacement = matcher.group("imageTagStart") + "cid:" + generatedCids.get(srcLocation) + matcher.group("imageSrcEnd");
final String imgSrcReplacement = matcher.group(1) + "cid:" + generatedCids.get(srcLocation) + matcher.group(3);
matcher.appendReplacement(stringBuffer, quoteReplacement(imgSrcReplacement));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1280,12 +1280,12 @@ public void call() {

private void verifyEmbeddedImage(final Email email, String expectedContainsWithContent)
throws IOException {
final String cidRegex = "<img src=\"cid:cid_name\"/><img src=\"cid:(?<cid>[a-z]{10})\"/>";
final String cidRegex = "<img src=\"cid:cid_name\"/><img src=\"cid:([a-z]{10})\"/>";
assertThat(email.getHTMLText()).matches(cidRegex);
final Matcher matcher = Pattern.compile(cidRegex).matcher(email.getHTMLText());
assertThat(matcher.find()).isTrue();
assertThat(email.getEmbeddedImages()).hasSize(1);
assertThat(email.getEmbeddedImages().get(0).getName()).isEqualTo(matcher.group("cid"));
assertThat(email.getEmbeddedImages().get(0).getName()).isEqualTo(matcher.group(1));
assertThat(email.getEmbeddedImages().get(0).readAllData()).contains(expectedContainsWithContent);
}

Expand Down