From f787a8a7a70e91d9281c3e17c7d9a2322830ec75 Mon Sep 17 00:00:00 2001 From: Ray Vincent Date: Tue, 24 Aug 2021 13:51:32 -0700 Subject: [PATCH] Update urn regex to match widely accepted expression --- include/valijson/internal/uri.hpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/include/valijson/internal/uri.hpp b/include/valijson/internal/uri.hpp index 6adc1e7..91b3fae 100644 --- a/include/valijson/internal/uri.hpp +++ b/include/valijson/internal/uri.hpp @@ -26,9 +26,7 @@ inline bool isUriAbsolute(const std::string &documentUri) */ inline bool isUrn(const std::string &documentUri) { static const std::regex pattern( - "^((urn)|(URN)):[a-zA-Z0-9]+[-]{0,1}[a-zA-Z0-9]+(:[-a-zA-Z0-9\\\\._~%!" - "$&'()\\/*+,;=]+)+(\\?[-a-zA-Z0-9\\\\._~%!$&'()\\/" - "*+,;:=]+){0,1}(#[-a-zA-Z0-9\\\\._~%!$&'()\\/*+,;:=]+){0,1}$"); + "^(?i:urn:(?!urn:)([a-z0-9][a-z0-9-]{1,31}):((?:[-a-z0-9()+,.:=@;$_!*'&~\\/]|%[0-9a-f]{2})+)(?:\\?\\+(.*?))?(?:\\?=(.*?))?(?:#(.*?))?)$"); return std::regex_match(documentUri, pattern); }