From 3442709aa7f5929e3696333ddb925b02bfec8738 Mon Sep 17 00:00:00 2001 From: Ray Vincent Date: Wed, 25 Aug 2021 16:55:01 -0700 Subject: [PATCH] Update urn regex expression to be std::regex safe --- include/valijson/internal/uri.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/valijson/internal/uri.hpp b/include/valijson/internal/uri.hpp index 91b3fae..17a9c9d 100644 --- a/include/valijson/internal/uri.hpp +++ b/include/valijson/internal/uri.hpp @@ -22,11 +22,11 @@ inline bool isUriAbsolute(const std::string &documentUri) /** * @brief Placeholder function to check whether a URI is a URN * - * This function validates that the URI matches the RFC 8141 + * This function validates that the URI matches the RFC 8141 spec */ inline bool isUrn(const std::string &documentUri) { static const std::regex pattern( - "^(?i:urn:(?!urn:)([a-z0-9][a-z0-9-]{1,31}):((?:[-a-z0-9()+,.:=@;$_!*'&~\\/]|%[0-9a-f]{2})+)(?:\\?\\+(.*?))?(?:\\?=(.*?))?(?:#(.*?))?)$"); + "^((urn)|(URN)):(?!urn:)([a-zA-Z0-9][a-zA-Z0-9-]{1,31})(:[-a-zA-Z0-9\\\\._~%!$&'()\\/*+,;=]+)+(\\?[-a-zA-Z0-9\\\\._~%!$&'()\\/*+,;:=]+){0,1}(#[-a-zA-Z0-9\\\\._~%!$&'()\\/*+,;:=]+){0,1}$"); return std::regex_match(documentUri, pattern); }