chxavurlfix.cpp
上传用户:zhongxx05
上传日期:2007-06-06
资源大小:33641k
文件大小:2k
- /*============================================================================*
- *
- * (c) 1995-2002 RealNetworks, Inc. Patents pending. All rights reserved.
- *
- *============================================================================*/
-
- // Helix includes...
- #include "hxsym_debug.h"
- #include "chxavescapedstring.h"
- #include "chxavurlfix.h"
- CHXAvURLRep CHXAvURLFixup::TryEscapeURL(const CHXAvURLRep& url)
- {
- CHXAvURLRep ret = url;
- if (!ret.Valid())
- {
- //
- // Url may be 'invalid' because there are unescaped characters.
- // 'Fix' it by trying to escape characters in the path and query
- //
- bool modified = false;
- // See if the path is invalid
- if (!ret.EscapedPath().ValidPath())
- {
- // Escape the path
- CHXAvEscapedString newPath;
- newPath.EscapePathStr(ret.EscapedPath().GetEscapedStr());
-
- ret = CHXAvURLRep(ret.Protocol(), ret.Host(), ret.Port(),
- newPath, ret.EscapedQuery());
- modified = true;
- }
- // See if the query is invalid
- if (!ret.EscapedQuery().ValidQuery())
- {
- // Escape the query
- CHXAvEscapedString newQuery;
- newQuery.EscapeQueryStr(ret.EscapedQuery().GetEscapedStr());
-
- ret = CHXAvURLRep(ret.Protocol(), ret.Host(), ret.Port(),
- ret.EscapedPath(), newQuery);
-
- modified = true;
- }
- if (modified)
- {
- DPRINTF (SYMP_INFO,
- ("CHXAvURLFixup::TryEscapeURL : old = '%s'n",
- (const char*)url.String()));
- DPRINTF (SYMP_INFO,
- ("CHXAvURLFixup::TryEscapeURL : new = '%s'n",
- (const char*)ret.String()));
- }
- }
- return ret;
- }