From 6d3ad95aecbb1ed18ac2d67da68e301ff6471ff6 Mon Sep 17 00:00:00 2001 From: Rasmus Wriedt Larsen Date: Tue, 22 Mar 2022 16:06:17 +0100 Subject: [PATCH] InlineExpectationsTest: Allow URLs as values For example, ```py requests.get("http://example.com") # $ clientRequestUrlPart="http://example.com" ``` would not have been allowed previously, since the `//` part of the value for the URL would have caused the rest of the line to be treated as a normal (non-interpreted) comment. Requiring a space before the `//` allows this specific example, while still support all the existing uses of `//` to break expectation tests, which is usually to add a comment explaining why the annotation is like it is. --- cpp/ql/test/TestUtilities/InlineExpectationsTest.qll | 4 ++-- csharp/ql/test/TestUtilities/InlineExpectationsTest.qll | 4 ++-- java/ql/test/TestUtilities/InlineExpectationsTest.qll | 4 ++-- python/ql/test/TestUtilities/InlineExpectationsTest.qll | 4 ++-- ruby/ql/test/TestUtilities/InlineExpectationsTest.qll | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cpp/ql/test/TestUtilities/InlineExpectationsTest.qll b/cpp/ql/test/TestUtilities/InlineExpectationsTest.qll index a4d264b2703c..b5e8f4a4d42c 100644 --- a/cpp/ql/test/TestUtilities/InlineExpectationsTest.qll +++ b/cpp/ql/test/TestUtilities/InlineExpectationsTest.qll @@ -173,10 +173,10 @@ abstract class InlineExpectationsTest extends string { /** * RegEx pattern to match a comment containing one or more expected results. The comment must have * `$` as its first non-whitespace character. Any subsequent character - * is treated as part of the expected results, except that the comment may contain a `//` sequence + * is treated as part of the expected results, except that the comment may contain a ` //` sequence * to treat the remainder of the line as a regular (non-interpreted) comment. */ -private string expectationCommentPattern() { result = "\\s*\\$((?:[^/]|/[^/])*)(?://.*)?" } +private string expectationCommentPattern() { result = "\\s*\\$((?:[^/]|[^ ]//|/[^/])*)(?: //.*)?" } /** * The possible columns in an expectation comment. The `TDefaultColumn` branch represents the first diff --git a/csharp/ql/test/TestUtilities/InlineExpectationsTest.qll b/csharp/ql/test/TestUtilities/InlineExpectationsTest.qll index a4d264b2703c..b5e8f4a4d42c 100644 --- a/csharp/ql/test/TestUtilities/InlineExpectationsTest.qll +++ b/csharp/ql/test/TestUtilities/InlineExpectationsTest.qll @@ -173,10 +173,10 @@ abstract class InlineExpectationsTest extends string { /** * RegEx pattern to match a comment containing one or more expected results. The comment must have * `$` as its first non-whitespace character. Any subsequent character - * is treated as part of the expected results, except that the comment may contain a `//` sequence + * is treated as part of the expected results, except that the comment may contain a ` //` sequence * to treat the remainder of the line as a regular (non-interpreted) comment. */ -private string expectationCommentPattern() { result = "\\s*\\$((?:[^/]|/[^/])*)(?://.*)?" } +private string expectationCommentPattern() { result = "\\s*\\$((?:[^/]|[^ ]//|/[^/])*)(?: //.*)?" } /** * The possible columns in an expectation comment. The `TDefaultColumn` branch represents the first diff --git a/java/ql/test/TestUtilities/InlineExpectationsTest.qll b/java/ql/test/TestUtilities/InlineExpectationsTest.qll index a4d264b2703c..b5e8f4a4d42c 100644 --- a/java/ql/test/TestUtilities/InlineExpectationsTest.qll +++ b/java/ql/test/TestUtilities/InlineExpectationsTest.qll @@ -173,10 +173,10 @@ abstract class InlineExpectationsTest extends string { /** * RegEx pattern to match a comment containing one or more expected results. The comment must have * `$` as its first non-whitespace character. Any subsequent character - * is treated as part of the expected results, except that the comment may contain a `//` sequence + * is treated as part of the expected results, except that the comment may contain a ` //` sequence * to treat the remainder of the line as a regular (non-interpreted) comment. */ -private string expectationCommentPattern() { result = "\\s*\\$((?:[^/]|/[^/])*)(?://.*)?" } +private string expectationCommentPattern() { result = "\\s*\\$((?:[^/]|[^ ]//|/[^/])*)(?: //.*)?" } /** * The possible columns in an expectation comment. The `TDefaultColumn` branch represents the first diff --git a/python/ql/test/TestUtilities/InlineExpectationsTest.qll b/python/ql/test/TestUtilities/InlineExpectationsTest.qll index a4d264b2703c..b5e8f4a4d42c 100644 --- a/python/ql/test/TestUtilities/InlineExpectationsTest.qll +++ b/python/ql/test/TestUtilities/InlineExpectationsTest.qll @@ -173,10 +173,10 @@ abstract class InlineExpectationsTest extends string { /** * RegEx pattern to match a comment containing one or more expected results. The comment must have * `$` as its first non-whitespace character. Any subsequent character - * is treated as part of the expected results, except that the comment may contain a `//` sequence + * is treated as part of the expected results, except that the comment may contain a ` //` sequence * to treat the remainder of the line as a regular (non-interpreted) comment. */ -private string expectationCommentPattern() { result = "\\s*\\$((?:[^/]|/[^/])*)(?://.*)?" } +private string expectationCommentPattern() { result = "\\s*\\$((?:[^/]|[^ ]//|/[^/])*)(?: //.*)?" } /** * The possible columns in an expectation comment. The `TDefaultColumn` branch represents the first diff --git a/ruby/ql/test/TestUtilities/InlineExpectationsTest.qll b/ruby/ql/test/TestUtilities/InlineExpectationsTest.qll index a4d264b2703c..b5e8f4a4d42c 100644 --- a/ruby/ql/test/TestUtilities/InlineExpectationsTest.qll +++ b/ruby/ql/test/TestUtilities/InlineExpectationsTest.qll @@ -173,10 +173,10 @@ abstract class InlineExpectationsTest extends string { /** * RegEx pattern to match a comment containing one or more expected results. The comment must have * `$` as its first non-whitespace character. Any subsequent character - * is treated as part of the expected results, except that the comment may contain a `//` sequence + * is treated as part of the expected results, except that the comment may contain a ` //` sequence * to treat the remainder of the line as a regular (non-interpreted) comment. */ -private string expectationCommentPattern() { result = "\\s*\\$((?:[^/]|/[^/])*)(?://.*)?" } +private string expectationCommentPattern() { result = "\\s*\\$((?:[^/]|[^ ]//|/[^/])*)(?: //.*)?" } /** * The possible columns in an expectation comment. The `TDefaultColumn` branch represents the first