AbstractJsonPartialMatcher: Regex Value is Uppercased when IgnoreCase is set to true #604

Closed
opened 2025-12-29 08:30:50 +01:00 by adam · 2 comments
Owner

Originally created by @epDugas on GitHub (Jun 8, 2024).

Originally assigned to: @StefH on GitHub.

Describe the bug

AbstractJsonPartialMatcher
When IgnoreCase is true, and Regex is true, the value used as a regex is upper-cased.
This changes a given regex and causes a non-match. Example:
"^\d+$" is changed to "^\D+$"

Expected behavior:

Expect the given regex to be used.

Test to reproduce

  • Create a request mapping, with Regex = true and IgnoreCase = true
  • Define json object with regex: { "x" : "^\d+$" }

Test to Demonstrate:

[Fact]
public void JsonPartialWildcardMatcher_IsMatch_WithIgnoreCaseTrueAndRegexTrue_JObject()
{
    // Assign 
    var matcher = new JsonPartialWildcardMatcher(new { id = 1, Number = "^\\d+$" }, true, true);

    // Act 
    var jObject = new JObject
    {
        { "Id", new JValue(1) },
        { "Number", new JValue(1) }
    };
    double match = matcher.IsMatch(jObject).Score;

    // Assert 
    Assert.Equal(1.0, match);
}
Originally created by @epDugas on GitHub (Jun 8, 2024). Originally assigned to: @StefH on GitHub. ### Describe the bug AbstractJsonPartialMatcher When IgnoreCase is true, and Regex is true, the value used as a regex is upper-cased. This changes a given regex and causes a non-match. Example: "^\d+$" is changed to "^\D+$" ### Expected behavior: Expect the given regex to be used. ### Test to reproduce - Create a request mapping, with Regex = true and IgnoreCase = true - Define json object with regex: { "x" : "^\\d+$" } ### Other related info Test to Demonstrate: ```csharp [Fact] public void JsonPartialWildcardMatcher_IsMatch_WithIgnoreCaseTrueAndRegexTrue_JObject() { // Assign var matcher = new JsonPartialWildcardMatcher(new { id = 1, Number = "^\\d+$" }, true, true); // Act var jObject = new JObject { { "Id", new JValue(1) }, { "Number", new JValue(1) } }; double match = matcher.IsMatch(jObject).Score; // Assert Assert.Equal(1.0, match); } ```
adam added the bug label 2025-12-29 08:30:50 +01:00
adam closed this issue 2025-12-29 08:30:50 +01:00
Author
Owner

@StefH commented on GitHub (Jun 8, 2024):

@epDugas Thanks for this finding.

A fix will be released shortly.

@StefH commented on GitHub (Jun 8, 2024): @epDugas Thanks for this finding. A fix will be released shortly.
Author
Owner

@StefH commented on GitHub (Jun 8, 2024):

86f8877039

@StefH commented on GitHub (Jun 8, 2024): https://github.com/WireMock-Net/WireMock.Net/commit/86f8877039d89674f4191f40b2d85320398167d1
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net#604