Skip to content

Commit

Permalink
Fix escaping some cases and add unittest (#619)
Browse files Browse the repository at this point in the history
IB-7996

Signed-off-by: Raul Metsma <[email protected]>
  • Loading branch information
metsma authored Aug 27, 2024
1 parent 721b83a commit d107ee5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/crypto/X509Crypto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ int X509Crypto::compareIssuerToString(string_view name) const
value[pos] = char(result);
value.erase(pos + 1, 2);
}
else if(escape.find(value[pos+1]) == string::npos)
else if(escape.find(value[pos+1]) != string::npos)
value.erase(pos, 1);
}

Expand Down
10 changes: 10 additions & 0 deletions test/data/comma.crt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-----BEGIN CERTIFICATE-----
MIIBcjCB+QIJAKIsqQxqAGX3MAoGCCqGSM49BAMCMCMxCzAJBgNVBAYTAkVFMRQw
EgYDVQQDDAt0ZXN0LCBjb21tYTAeFw0yNDA4MjcwODM4MDlaFw0yNTA4MjcwODM4
MDlaMCMxCzAJBgNVBAYTAkVFMRQwEgYDVQQDDAt0ZXN0LCBjb21tYTB2MBAGByqG
SM49AgEGBSuBBAAiA2IABKoUm0pDszqGu4HyjABAYB0FhAgEN+G1QNEEEXjz0jRK
rlu7PqV3Bj+4Wz222KBUpViaZZdTuZFLDbEL7legmfNMeOiQK2SQiYRrclFhZVaE
laqSW0BNqI6wIevp/IgSmjAKBggqhkjOPQQDAgNoADBlAjBFyjog1pDn0J5azKuK
AwTqnTVYxWgeNsYpfgzQ1BYs9jEs/x/FoEgRX7sqeL9TCksCMQC6CG34jBdM3stY
1czLqKJjqRgZ9yg4wSgPABHYICjTW0TfuCTPLa7pMlL6mrWeAhg=
-----END CERTIFICATE-----
2 changes: 2 additions & 0 deletions test/libdigidocpp_boost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ BOOST_AUTO_TEST_CASE(parameters)

X509Crypto test(X509Cert("test.crt", X509Cert::Pem));
BOOST_CHECK_EQUAL(test.compareIssuerToString("CN=\\\"test\\\""), 0);
X509Crypto comma(X509Cert("comma.crt", X509Cert::Pem));
BOOST_CHECK_EQUAL(comma.compareIssuerToString("CN=test\\, comma"), 0);
}
BOOST_AUTO_TEST_SUITE_END()

Expand Down

0 comments on commit d107ee5

Please sign in to comment.