
When an include is not surrounded by empty lines, its content is inlined on the same line as the adjacent content. That can lead to broken tags and other display issues. This PR fixes all such includes and introduces a validation step that forbids introducing the same problem again.
46 lines
1.3 KiB
Plaintext
46 lines
1.3 KiB
Plaintext
== Why is this an issue?
|
|
|
|
When a back reference in a regex refers to a capturing group that hasn't been defined yet (or at all), it can never be matched. Named back references throw a ``++PatternSyntaxException++`` in that case; numeric back references fail silently when they can't match, simply making the match fail.
|
|
|
|
|
|
When the group is defined before the back reference but on a different control path (like in ``++(.)|\1++`` for example), this also leads to a situation where the back reference can never match.
|
|
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,java]
|
|
----
|
|
Pattern.compile("\\1(.)"); // Noncompliant, group 1 is defined after the back reference
|
|
Pattern.compile("(.)\\2"); // Noncompliant, group 2 isn't defined at all
|
|
Pattern.compile("(.)|\\1"); // Noncompliant, group 1 and the back reference are in different branches
|
|
Pattern.compile("(?<x>.)|\\k<x>"); // Noncompliant, group x and the back reference are in different branches
|
|
----
|
|
|
|
|
|
=== Compliant solution
|
|
|
|
[source,java]
|
|
----
|
|
Pattern.compile("(.)\\1");
|
|
Pattern.compile("(?<x>.)\\k<x>");
|
|
----
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::../message.adoc[]
|
|
|
|
include::../highlighting.adoc[]
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
include::../comments-and-links.adoc[]
|
|
|
|
endif::env-github,rspecator-view[]
|