On Mon, 2009-12-28 at 18:03 -0500, Dale Worley wrote: > There is a problem with URI parsing that shows up as this error in the > unit tests: > > 1) test: UrlTest::testBigUriScheme (F) line: 1756 > /home/dworley/sandbox-162/sipX/./sipXtackLib/src/test/net/UrlTest.cpp > assertion failed > - Expression: bigschemeUrl.getScheme() == Url::UnknownUrlScheme > - BUG XPB-843: fails on FC6 > > Some investigation shows that the same problem shows up when turning > into a Url any string of the form "letters junk", e.g., "a!". Because > we are willing to allow the specification of the "sip" scheme to be > omitted, the initial portion of the string is interpreted as > "sip:[host-name]", e.g., "sip:a". But because the Url::parseString > method that does the real work can be used to parse strings that contain > multiple URIs separated with commas, Url::parseString does not declare > an error if the input string can be parsed as a URI followed by > extraneous text, it (thinks that it) returns a pointer to the extraneous > text and returns the parsed form of the URI portion. > > The result is that most or all strings that start with a letter can be > parsed as URIs without a detected error. > > I think that the proper fix is to revise Url::parseString to sharpen its > error detection: > > - if the nextUri parameter (which returns the un-parsed trailing > characters) is NULL, then the parse must consume all of the input string > (urlString). (If uriForm == NameAddr, there may be trailing SWS.) > > - if nextUri is not NULL, the parse must consume all of the input > string, or the parsed portion must be followed by a comma (and > surrounding SWS). > > If these conditions are not met, Url::parseString will return false > (indicating parse failed) and set the scheme of the constructed Url to > UnknownUrlScheme. > > If Url::parseString is adjusted this way, all of the Url constructors > and other users of parseString can be tweaked to provide the behavior > one intuitively expects, viz., if there is no specified way for the > parsing operation to return information about trailing text, the parse > must consume the entire input string.
Yes, that sounds like a good idea. _______________________________________________ sipx-dev mailing list [email protected] List Archive: http://list.sipfoundry.org/archive/sipx-dev Unsubscribe: http://list.sipfoundry.org/mailman/listinfo/sipx-dev sipXecs IP PBX -- http://www.sipfoundry.org/
