I think the problem is here: https://github.com/openstack-infra/config/blob/d19e0dd58eea7f075ae4f060872f185205268bcd/modules/openstack_project/manifests/gerrit.pp#L154
I don't understand why the launchpad.net bug URLs need truncating in the first place, but I believe the fix is to change the regex to the following:
<a href=\"(https://bugs\\.launchpad\\.net/[a-zA-Z0-9\\-]+/\\+bug/(\\d+))[^\"]*\">[^<]+</a>
As tested by the following Java:
import java.util.regex.Matcher; import java.util.regex.Pattern;
public class Test {
public static void showProblem() { System.out.println("Problem"); String r = "<a href=\"(https://bugs\\.launchpad\\.net/[a-zA-Z0-9\\-]+/\\+bug/(\\d+))[^\"]+\">[^<]+</a>"; String i = "<a href=\"https://bugs.launchpad.net/trove/+bug/1276858\">https://bugs.launchpad.net/trove/+bug/1276858</a>"; String i2 = "<a href=\"https://bugs.launchpad.net/trove/+bug/1222891/comments/3\">https://bugs.launchpad.net/trove/+bug/1222891/comments/3</a>"; Pattern pattern = Pattern.compile(r); Matcher matcher = pattern.matcher(i); matcher.find(); System.out.println("Orig: " + i); System.out.println(String.format("New: <a href=\"%s\">%s</a>", matcher.group(1), matcher.group(1))); matcher = pattern.matcher(i2); matcher.find(); System.out.println("Orig: " + i2); System.out.println(String.format("New: <a href=\"%s\">%s</a>", matcher.group(1), matcher.group(1))); }
public static void showSolution() { System.out.println("\nSolution"); String r = "<a href=\"(https://bugs\\.launchpad\\.net/[a-zA-Z0-9\\-]+/\\+bug/(\\d+))[^\"]*\">[^<]+</a>"; String i = "<a href=\"https://bugs.launchpad.net/trove/+bug/1276858\">https://bugs.launchpad.net/trove/+bug/1276858</a>"; String i2 = "<a href=\"https://bugs.launchpad.net/trove/+bug/1222891/comments/3\">https://bugs.launchpad.net/trove/+bug/1222891/comments/3</a>"; Pattern pattern = Pattern.compile(r); Matcher matcher = pattern.matcher(i); matcher.find(); System.out.println("Orig: " + i); System.out.println(String.format("New: <a href=\"%s\">%s</a>", matcher.group(1), matcher.group(1))); matcher = pattern.matcher(i2); matcher.find(); System.out.println("Orig: " + i2); System.out.println(String.format("New: <a href=\"%s\">%s</a>", matcher.group(1), matcher.group(1))); }
public static void main(String []args) { showProblem(); showSolution(); } }
And its output:
Problem Orig: <a href="https://bugs.launchpad.net/trove/+bug/1276858">https://bugs.launchpad.net/trove/+bug/1276858</a> New: <a href="https://bugs.launchpad.net/trove/+bug/127685">https://bugs.launchpad.net/trove/+bug/127685</a> Orig: <a href="https://bugs.launchpad.net/trove/+bug/1222891/comments/3">https://bugs.launchpad.net/trove/+bug/1222891/comments/3</a> New: <a href="https://bugs.launchpad.net/trove/+bug/1222891">https://bugs.launchpad.net/trove/+bug/1222891</a>
Solution Orig: <a href="https://bugs.launchpad.net/trove/+bug/1276858">https://bugs.launchpad.net/trove/+bug/1276858</a> New: <a href="https://bugs.launchpad.net/trove/+bug/1276858">https://bugs.launchpad.net/trove/+bug/1276858</a> Orig: <a href="https://bugs.launchpad.net/trove/+bug/1222891/comments/3">https://bugs.launchpad.net/trove/+bug/1222891/comments/3</a> New: <a href="https://bugs.launchpad.net/trove/+bug/1222891">https://bugs.launchpad.net/trove/+bug/1222891</a>
I think the problem is here: https:/ /github. com/openstack- infra/config/ blob/d19e0dd58e ea7f075ae4f0608 72f185205268bcd /modules/ openstack_ project/ manifests/ gerrit. pp#L154
I don't understand why the launchpad.net bug URLs need truncating in the first place, but I believe the fix is to change the regex to the following:
<a href=\"(https:/ /bugs\\.launchpad\ \.net/[ a-zA-Z0- 9\\-]+/ \\+bug/ (\\d+)) [^\"]*\ ">[^<]+ </a>
As tested by the following Java:
import java.util. regex.Matcher; regex.Pattern;
import java.util.
public class Test {
public static void showProblem() {
System. out.println( "Problem" ); /bugs\\.launchpad\ \.net/[ a-zA-Z0- 9\\-]+/ \\+bug/ (\\d+)) [^\"]+\ ">[^<]+ </a>"; /bugs.launchpad .net/trove/ +bug/1276858\">https:/ /bugs.launchpad .net/trove/ +bug/1276858</a>"; /bugs.launchpad .net/trove/ +bug/1222891/ comments/ 3\">https:/ /bugs.launchpad .net/trove/ +bug/1222891/ comments/ 3</a>";
matcher. find();
System. out.println( "Orig: " + i);
System. out.println( String. format( "New: <a href=\" %s\">%s< /a>", matcher.group(1), matcher.group(1))); matcher( i2);
matcher. find();
System. out.println( "Orig: " + i2);
System. out.println( String. format( "New: <a href=\" %s\">%s< /a>", matcher.group(1), matcher.group(1)));
String r = "<a href=\"(https:/
String i = "<a href=\"https:/
String i2 = "<a href=\"https:/
Pattern pattern = Pattern.compile(r);
Matcher matcher = pattern.matcher(i);
matcher = pattern.
}
public static void showSolution() {
System. out.println( "\nSolution" ); /bugs\\.launchpad\ \.net/[ a-zA-Z0- 9\\-]+/ \\+bug/ (\\d+)) [^\"]*\ ">[^<]+ </a>"; /bugs.launchpad .net/trove/ +bug/1276858\">https:/ /bugs.launchpad .net/trove/ +bug/1276858</a>"; /bugs.launchpad .net/trove/ +bug/1222891/ comments/ 3\">https:/ /bugs.launchpad .net/trove/ +bug/1222891/ comments/ 3</a>";
matcher. find();
System. out.println( "Orig: " + i);
System. out.println( String. format( "New: <a href=\" %s\">%s< /a>", matcher.group(1), matcher.group(1))); matcher( i2);
matcher. find();
System. out.println( "Orig: " + i2);
System. out.println( String. format( "New: <a href=\" %s\">%s< /a>", matcher.group(1), matcher.group(1)));
String r = "<a href=\"(https:/
String i = "<a href=\"https:/
String i2 = "<a href=\"https:/
Pattern pattern = Pattern.compile(r);
Matcher matcher = pattern.matcher(i);
matcher = pattern.
}
public static void main(String []args) {
showProblem( );
showSolution( );
}
}
And its output:
Problem /bugs.launchpad .net/trove/ +bug/1276858">https:/ /bugs.launchpad .net/trove/ +bug/1276858</a> /bugs.launchpad .net/trove/ +bug/127685">https:/ /bugs.launchpad .net/trove/ +bug/127685</a> /bugs.launchpad .net/trove/ +bug/1222891/ comments/ 3">https:/ /bugs.launchpad .net/trove/ +bug/1222891/ comments/ 3</a> /bugs.launchpad .net/trove/ +bug/1222891">https:/ /bugs.launchpad .net/trove/ +bug/1222891</a>
Orig: <a href="https:/
New: <a href="https:/
Orig: <a href="https:/
New: <a href="https:/
Solution /bugs.launchpad .net/trove/ +bug/1276858">https:/ /bugs.launchpad .net/trove/ +bug/1276858</a> /bugs.launchpad .net/trove/ +bug/1276858">https:/ /bugs.launchpad .net/trove/ +bug/1276858</a> /bugs.launchpad .net/trove/ +bug/1222891/ comments/ 3">https:/ /bugs.launchpad .net/trove/ +bug/1222891/ comments/ 3</a> /bugs.launchpad .net/trove/ +bug/1222891">https:/ /bugs.launchpad .net/trove/ +bug/1222891</a>
Orig: <a href="https:/
New: <a href="https:/
Orig: <a href="https:/
New: <a href="https:/