Mercurial > hg > svcore
diff data/fileio/FileSource.cpp @ 614:87b81f959706
* Convert strings to URLs in strict mode first; only try again in tolerant
mode if this fails (and if the file is local)
author | Chris Cannam |
---|---|
date | Wed, 07 Oct 2009 13:10:49 +0000 |
parents | d7f3dfe6f9a4 |
children | 3a61a4df6d53 |
line wrap: on
line diff
--- a/data/fileio/FileSource.cpp Tue Sep 29 10:34:57 2009 +0000 +++ b/data/fileio/FileSource.cpp Wed Oct 07 13:10:49 2009 +0000 @@ -70,7 +70,7 @@ FileSource::FileSource(QString fileOrUrl, ProgressReporter *reporter, QString preferredContentType) : - m_url(fileOrUrl), + m_url(fileOrUrl, QUrl::StrictMode), m_ftp(0), m_http(0), m_localFile(0), @@ -96,6 +96,15 @@ init(); + if (!isRemote() && + !isAvailable()) { +#ifdef DEBUG_FILE_SOURCE + std::cerr << "FileSource::FileSource: Failed to open local file with URL \"" << m_url.toString().toStdString() << "; trying again with tolerant encoding" << std::endl; +#endif + m_url = QUrl(fileOrUrl, QUrl::TolerantMode); + init(); + } + if (isRemote() && (fileOrUrl.contains('%') || fileOrUrl.contains("--"))) { // for IDNA @@ -263,12 +272,12 @@ m_lastStatus = 200; if (!QFileInfo(m_localFilename).exists()) { -#ifdef DEBUG_FILE_SOURCE - std::cerr << "FileSource::init: Local file of this name does not exist, trying URL as a literal filename" << std::endl; -#endif if (literal) { m_lastStatus = 404; } else { +#ifdef DEBUG_FILE_SOURCE + std::cerr << "FileSource::init: Local file of this name does not exist, trying URL as a literal filename" << std::endl; +#endif // Again, QUrl may have been mistreating us -- // e.g. dropping a part that looks like query data m_localFilename = m_url.toString();