# HG changeset patch # User Chris Cannam # Date 1254921049 0 # Node ID 87b81f959706b309ccf2a2c19203021b29544a26 # Parent eb1b517f5eeb2847374394683dbd835088e84b18 * Convert strings to URLs in strict mode first; only try again in tolerant mode if this fails (and if the file is local) diff -r eb1b517f5eeb -r 87b81f959706 data/fileio/FileSource.cpp --- 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();