Commit 66a19866 authored by Karsten Loesing's avatar Karsten Loesing
Browse files

Support email addresses in qualified search terms.

More generally, accept the same characters in qualified search terms
as in their parameter equivalents.

This includes the '@' sign and others in search terms like
'contact:user@domain.com', which were supported in the contact
parameter but not in the search parameter before.

Fixes #10972.
parent b094894d
......@@ -4,6 +4,8 @@
- Unify the build process by adding git-submodule metrics-base in
src/build and removing all centralized parts of the build
process.
- Accept the same characters in qualified search terms as in their
parameter equivalents.
# Changes in version 3.1-1.0.0 - 2016-11-23
......
......@@ -362,7 +362,7 @@ public class ResourceServlet extends HttpServlet {
private static Pattern searchQueryStringPattern =
Pattern.compile("(?:.*[\\?&])*?" // lazily skip other parameters
+ "search=([0-9a-zA-Z+/\\.: \\$\\[\\]%]+)" // capture parameter
+ "search=([\\p{Graph} &&[^&]]+)" // capture parameter
+ "(?:&.*)*"); // skip remaining parameters
private static Pattern searchParameterPattern =
......@@ -370,7 +370,7 @@ public class ResourceServlet extends HttpServlet {
+ "^[0-9a-zA-Z+/]{1,27}$|" /* Base64 fingerprint. */
+ "^[0-9a-zA-Z\\.]{1,19}$|" /* Nickname or IPv4 address. */
+ "^\\[[0-9a-fA-F:\\.]{1,39}\\]?$|" /* IPv6 address. */
+ "^[a-zA-Z_]+:[0-9a-zA-Z_,-]+$" /* Qualified search term. */);
+ "^[a-zA-Z_]+:\\p{Graph}+$" /* Qualified search term. */);
protected static String[] parseSearchParameters(String queryString) {
Matcher searchQueryStringMatcher = searchQueryStringPattern.matcher(
......
......@@ -869,6 +869,14 @@ public class ResourceServletTest {
this.assertErrorStatusCode("/summary?search=limit:1", 400);
}
@Test()
public void testSearchEmailAddress() {
this.assertSummaryDocument(
"/summary?search=contact:<tor+steven.murdoch@cl.cam.ac.uk>", 1,
new String[] { "TimMayTribute" }, 0, null);
}
@Test()
public void testLookupFingerprint() {
this.assertSummaryDocument(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment