Permalink
Browse files

Fix backend webserver when html dir path contains a link.

Use canonicalPath() consistently in the directory path checking.
This fixes an issue where the backend webserver would not serve
up static content if the html directory was in a path which
contained one or more links.
(cherry picked from commit 381c2eb)
  • Loading branch information...
1 parent 5a51df7 commit 4f6ac2a60b668804ff33bd696c61da0f1437d7a6 @cpinkham cpinkham committed Jul 13, 2012
Showing with 6 additions and 13 deletions.
  1. +5 −12 mythtv/libs/libmythupnp/htmlserver.cpp
  2. +1 −1 mythtv/libs/libmythupnp/htmlserver.h
View
17 mythtv/libs/libmythupnp/htmlserver.cpp
@@ -27,23 +27,18 @@ HtmlServerExtension::HtmlServerExtension( const QString sSharePath,
: HttpServerExtension( "Html" , sSharePath),
m_IndexFilename(sApplicationPrefix + "index")
{
- // Cache the absolute path for the share directory.
+ // Cache the canonical path for the share directory.
QDir dir( sSharePath + "/html" );
- dir.makeAbsolute();
-
- m_sAbsoluteSharePath = dir.absolutePath();
-
if (getenv("MYTHHTMLDIR"))
{
QString sTempSharePath = getenv("MYTHHTMLDIR");
if (!sTempSharePath.isEmpty())
- {
dir.setPath( sTempSharePath );
- m_sAbsoluteSharePath = dir.absolutePath();
- }
}
+
+ m_sSharePath = dir.canonicalPath();
}
/////////////////////////////////////////////////////////////////////////////
@@ -66,7 +61,7 @@ bool HtmlServerExtension::ProcessRequest( HTTPRequest *pRequest )
return( false );
bool bStorageGroupFile = false;
- QFileInfo oInfo( m_sAbsoluteSharePath + pRequest->m_sResourceUrl );
+ QFileInfo oInfo( m_sSharePath + pRequest->m_sResourceUrl );
if (oInfo.isDir())
{
@@ -92,16 +87,14 @@ bool HtmlServerExtension::ProcessRequest( HTTPRequest *pRequest )
if (bStorageGroupFile || oInfo.exists() == true )
{
- oInfo.makeAbsolute();
-
QString sResName = oInfo.canonicalFilePath();
// --------------------------------------------------------------
// Checking for url's that contain ../ or similar.
// --------------------------------------------------------------
if (( bStorageGroupFile ) ||
- (sResName.startsWith( m_sAbsoluteSharePath, Qt::CaseInsensitive )))
+ (sResName.startsWith( m_sSharePath, Qt::CaseInsensitive )))
{
if (oInfo.exists())
{
View
2 mythtv/libs/libmythupnp/htmlserver.h
@@ -28,7 +28,7 @@ class UPNP_PUBLIC HtmlServerExtension : public HttpServerExtension
{
private:
- QString m_sAbsoluteSharePath;
+ QString m_sSharePath;
ServerSideScripting m_Scripting;
QString m_IndexFilename;

0 comments on commit 4f6ac2a

Please sign in to comment.