Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #1 from jaybuff/master

add back in URI checking regex
  • Loading branch information...
commit d3ed18ff4923156043fb12f5a179a3b3655c7ba6 2 parents a8f6dad + 5e15338
@jaybuff jaybuff authored
Showing with 6 additions and 7 deletions.
  1. +6 −7 gearbox/core/JsonSchema.cc
View
13 gearbox/core/JsonSchema.cc
@@ -54,13 +54,12 @@ static bool DateFormatChecker(const std::string & value) {
}
static bool UriFormatChecker(const std::string & value) {
- //TODO replace XXX with regex taken from: perl -MRegexp::Common=URI -e 'print $RE{URI}' | perl -pi -e 's/http/https?/; s/\\/\\\\/g'
- //static boost::regex rx(
- // "XXX",
- // boost::regex::perl
- //);
- //return regex_match(value, rx);
- return true;
+ // regex taken from: perl -MRegexp::Common=URI -e 'print $RE{URI}' | perl -pi -e 's/http/https?/; s/\\/\\\\/g'
+ static boost::regex rx(
+ "(?:(?:(?:https?)://(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-zA-Z0-9]*[a-zA-Z0-9]|[a-zA-Z])[.]?)|(?:[0-9]+[.][0-9]+[.][0-9]+[.][0-9]+)))(?::(?:(?:[0-9]*)))?(?:/(?:(?:(?:(?:(?:(?:[a-zA-Z0-9\\-_.!~*'():@&=+$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)(?:;(?:(?:[a-zA-Z0-9\\-_.!~*'():@&=+$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*))*)(?:/(?:(?:(?:[a-zA-Z0-9\\-_.!~*'():@&=+$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)(?:;(?:(?:[a-zA-Z0-9\\-_.!~*'():@&=+$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*))*))*))(?:[?](?:(?:(?:[;/?:@&=+$,a-zA-Z0-9\\-_.!~*'()]+|(?:%[a-fA-F0-9][a-fA-F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a-zA-Z]))|(?:[0-9]+[.][0-9]+[.][0-9]+[.][0-9]+)))(?::(?:(?:[0-9]+)))?/(?:(?:(?:[0-9+IgT]))(?:(?:(?:[-a-zA-Z0-9$_.+!*'(),:@&=]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*))))|(?:(?:pop)://(?:(?:(?:(?:[-a-zA-Z0-9$_.+!*'(),&=~]+|(?:%[a-fA-F0-9][a-fA-F0-9]))+))(?:;AUTH=(?:[*]|(?:(?:(?:[-a-zA-Z0-9$_.+!*'(),&=~]+|(?:%[a-fA-F0-9][a-fA-F0-9]))+)|(?:[+](?:APOP|(?:(?:[-a-zA-Z0-9$_.+!*'(),&=~]+|(?:%[a-fA-F0-9][a-fA-F0-9]))+))))))?@)?(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-zA-Z0-9]*[a-zA-Z0-9]|[a-zA-Z]))|(?:[0-9]+[.][0-9]+[.][0-9]+[.][0-9]+)))(?::(?:(?:[0-9]+)))?))",
+ boost::regex::perl
+ );
+ return regex_match(value, rx);
}
static bool Ipv4FormatChecker( const std::string & value ) {
Please sign in to comment.
Something went wrong with that request. Please try again.