[zypp-commit] r6597 - /trunk/libzypp/zypp/url/UrlBase.cc
Author: dmacvicar Date: Fri Aug 10 16:08:35 2007 New Revision: 6597 URL: http://svn.opensuse.org/viewcvs/zypp?rev=6597&view=rev Log: reducing diff Modified: trunk/libzypp/zypp/url/UrlBase.cc Modified: trunk/libzypp/zypp/url/UrlBase.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/url/UrlBase.cc?rev=6597&r1=6596&r2=6597&view=diff ============================================================================== --- trunk/libzypp/zypp/url/UrlBase.cc (original) +++ trunk/libzypp/zypp/url/UrlBase.cc Fri Aug 10 16:08:35 2007 @@ -31,6 +31,8 @@ */ #define RX_VALID_SCHEME "^[a-zA-Z][a-zA-Z0-9\\.+-]*$" +#define RX_VALID_PORT "^[0-9]{1,5}$" + #define RX_VALID_HOSTNAME "^[[:alnum:]]+([\\.-][[:alnum:]]+)*$" #define RX_VALID_HOSTIPV4 \ @@ -1336,11 +1338,17 @@ bool UrlBase::isValidPort(const std::string &port) const { - char* endptr; - long pnum = strtol(port.c_str(), &endptr, 10); - return ( !port.empty() && !*endptr - && pnum >= 1 && pnum <= USHRT_MAX); - + try + { + str::regex regx(RX_VALID_PORT); + if( str::regex_match(port, regx)) + { + long pnum = str::strtonum<long>(port); + return ( pnum >= 1 && pnum <= USHRT_MAX); + } + } + catch( ... ) + {} return false; } -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org
participants (1)
-
dmacvicar@svn.opensuse.org