mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
Make JSResolver::escape public and use it from JSInfoPlugin
This commit is contained in:
@@ -59,7 +59,7 @@ JSInfoPlugin::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||
.arg( d->id ) // infoPluginId
|
||||
.arg( requestData.requestId ) // requestId
|
||||
.arg( requestData.type ) // type
|
||||
.arg( serializeQVariantMap( convertInfoStringHashToQVariantMap( requestData.input.value<Tomahawk::InfoSystem::InfoStringHash>() ) ) ); // infoHash
|
||||
.arg( JSResolver::escape( serializeQVariantMap( convertInfoStringHashToQVariantMap( requestData.input.value<Tomahawk::InfoSystem::InfoStringHash>() ) ) ) ); // infoHash
|
||||
|
||||
callMethodOnInfoPlugin( eval );
|
||||
}
|
||||
@@ -73,8 +73,8 @@ JSInfoPlugin::pushInfo( Tomahawk::InfoSystem::InfoPushData pushData )
|
||||
QString eval = QString( "pushInfo({ type: %1, pushFlags: %2, input: %3, additionalInput: %4})" )
|
||||
.arg( pushData.type )
|
||||
.arg( pushData.pushFlags )
|
||||
.arg( serializeQVariantMap ( pushData.infoPair.second.toMap() ) )
|
||||
.arg( serializeQVariantMap( pushData.infoPair.first ) );
|
||||
.arg( JSResolver::escape( serializeQVariantMap ( pushData.infoPair.second.toMap() ) ) )
|
||||
.arg( JSResolver::escape( serializeQVariantMap( pushData.infoPair.first ) ) );
|
||||
|
||||
callMethodOnInfoPlugin( eval );
|
||||
}
|
||||
@@ -93,7 +93,7 @@ JSInfoPlugin::notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tom
|
||||
.arg( d->id )
|
||||
.arg( requestData.requestId )
|
||||
.arg( requestData.type )
|
||||
.arg( serializeQVariantMap( convertInfoStringHashToQVariantMap( criteria ) ) );
|
||||
.arg( JSResolver::escape( serializeQVariantMap( convertInfoStringHashToQVariantMap( criteria ) ) ) );
|
||||
|
||||
callMethodOnInfoPlugin( eval );
|
||||
}
|
||||
|
@@ -1022,5 +1022,6 @@ JSResolver::callOnResolver( const QString& scriptSource )
|
||||
|
||||
QString JSResolver::escape( const QString& source )
|
||||
{
|
||||
return source.replace( "\\", "\\\\" ).replace( "'", "\\'" );
|
||||
QString copy = source;
|
||||
return copy.replace( "\\", "\\\\" ).replace( "'", "\\'" );
|
||||
}
|
||||
|
@@ -71,6 +71,10 @@ public:
|
||||
*/
|
||||
QVariant evaluateJavaScriptWithResult( const QString& scriptSource );
|
||||
|
||||
/**
|
||||
* Escape \ and ' in strings so they are safe to use in JavaScript
|
||||
*/
|
||||
static QString escape( const QString& source );
|
||||
|
||||
public slots:
|
||||
void resolve( const Tomahawk::query_ptr& query ) override;
|
||||
@@ -111,11 +115,6 @@ private:
|
||||
*/
|
||||
QVariant evaluateJavaScriptInternal( const QString& scriptSource );
|
||||
|
||||
/**
|
||||
* Escape \ and ' in strings so they are safe to use in JavaScript
|
||||
*/
|
||||
static QString escape( const QString& source );
|
||||
|
||||
// encapsulate javascript calls
|
||||
QVariantMap resolverSettings();
|
||||
QVariantMap resolverUserConfig();
|
||||
|
Reference in New Issue
Block a user