mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-13 17:43:59 +02:00
* Whitelist more staticdata.
This commit is contained in:
@@ -313,24 +313,43 @@ Api_v1::resolve( QxtWebRequestEvent* event )
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Api_v1::staticdata( QxtWebRequestEvent* event, const QString& str )
|
Api_v1::staticdata( QxtWebRequestEvent* event, const QString& file )
|
||||||
{
|
{
|
||||||
tDebug( LOGVERBOSE ) << "STATIC request:" << event << str;
|
tDebug( LOGVERBOSE ) << "STATIC request:" << event << file;
|
||||||
|
|
||||||
|
bool whitelisted = ( file == QString( "tomahawk_auth_logo.png" ) ||
|
||||||
|
file.startsWith( "css/" ) ||
|
||||||
|
file.startsWith( "js/" ) );
|
||||||
|
|
||||||
bool whitelisted = ( str == QString( "tomahawk_auth_logo.png" ) );
|
|
||||||
if ( whitelisted )
|
if ( whitelisted )
|
||||||
{
|
{
|
||||||
QFile f( RESPATH "www/" + str );
|
QFile f( RESPATH "www/" + file );
|
||||||
f.open( QIODevice::ReadOnly );
|
f.open( QIODevice::ReadOnly );
|
||||||
QByteArray data = f.readAll();
|
QByteArray data = f.readAll();
|
||||||
|
|
||||||
QxtWebPageEvent* e = new QxtWebPageEvent( event->sessionID, event->requestID, data );
|
QxtWebPageEvent* e = new QxtWebPageEvent( event->sessionID, event->requestID, data );
|
||||||
|
|
||||||
if ( str.endsWith( ".png" ) )
|
if ( file.endsWith( ".png" ) )
|
||||||
e->contentType = "image/png";
|
e->contentType = "image/png";
|
||||||
|
if ( file.endsWith( ".css" ) )
|
||||||
|
e->contentType = "text/css";
|
||||||
|
if ( file.endsWith( ".js" ) )
|
||||||
|
e->contentType = "application/javascript";
|
||||||
|
|
||||||
postEvent( e );
|
postEvent( e );
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
send404( event );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Api_v1::staticdata( QxtWebRequestEvent* event, const QString& path, const QString& file )
|
||||||
|
{
|
||||||
|
return staticdata( event, path + "/" + file );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -67,7 +67,8 @@ public slots:
|
|||||||
void stat( QxtWebRequestEvent* event );
|
void stat( QxtWebRequestEvent* event );
|
||||||
void statResult( const QString& clientToken, const QString& name, bool valid );
|
void statResult( const QString& clientToken, const QString& name, bool valid );
|
||||||
void resolve( QxtWebRequestEvent* event );
|
void resolve( QxtWebRequestEvent* event );
|
||||||
void staticdata( QxtWebRequestEvent* event, const QString& str );
|
void staticdata( QxtWebRequestEvent* event, const QString& file );
|
||||||
|
void staticdata( QxtWebRequestEvent* event, const QString& path, const QString& file );
|
||||||
void get_results( QxtWebRequestEvent* event );
|
void get_results( QxtWebRequestEvent* event );
|
||||||
void sendJSON( const QVariantMap& m, QxtWebRequestEvent* event );
|
void sendJSON( const QVariantMap& m, QxtWebRequestEvent* event );
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user