mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-30 09:10:53 +02:00
Escape \ in JS function call arguments
This commit is contained in:
@@ -344,7 +344,7 @@ JSResolver::artists( const Tomahawk::collection_ptr& collection )
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString eval = QString( "resolver.artists( '%1' );" )
|
QString eval = QString( "resolver.artists( '%1' );" )
|
||||||
.arg( collection->name().replace( "'", "\\'" ) );
|
.arg( collection->name().replace( "\\", "\\\\" ).replace( "'", "\\'" ) );
|
||||||
|
|
||||||
QVariantMap m = d->engine->mainFrame()->evaluateJavaScript( eval ).toMap();
|
QVariantMap m = d->engine->mainFrame()->evaluateJavaScript( eval ).toMap();
|
||||||
if ( m.isEmpty() )
|
if ( m.isEmpty() )
|
||||||
@@ -380,8 +380,8 @@ JSResolver::albums( const Tomahawk::collection_ptr& collection, const Tomahawk::
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString eval = QString( "resolver.albums( '%1', '%2' );" )
|
QString eval = QString( "resolver.albums( '%1', '%2' );" )
|
||||||
.arg( collection->name().replace( "'", "\\'" ) )
|
.arg( collection->name().replace( "\\", "\\\\" ).replace( "'", "\\'" ) )
|
||||||
.arg( artist->name().replace( "'", "\\'" ) );
|
.arg( artist->name().replace( "\\", "\\\\" ).replace( "'", "\\'" ) );
|
||||||
|
|
||||||
QVariantMap m = d->engine->mainFrame()->evaluateJavaScript( eval ).toMap();
|
QVariantMap m = d->engine->mainFrame()->evaluateJavaScript( eval ).toMap();
|
||||||
if ( m.isEmpty() )
|
if ( m.isEmpty() )
|
||||||
@@ -417,9 +417,9 @@ JSResolver::tracks( const Tomahawk::collection_ptr& collection, const Tomahawk::
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString eval = QString( "resolver.tracks( '%1', '%2', '%3' );" )
|
QString eval = QString( "resolver.tracks( '%1', '%2', '%3' );" )
|
||||||
.arg( collection->name().replace( "'", "\\'" ) )
|
.arg( collection->name().replace( "\\", "\\\\" ).replace( "'", "\\'" ) )
|
||||||
.arg( album->artist()->name().replace( "'", "\\'" ) )
|
.arg( album->artist()->name().replace( "\\", "\\\\" ).replace( "'", "\\'" ) )
|
||||||
.arg( album->name().replace( "'", "\\'" ) );
|
.arg( album->name().replace( "\\", "\\\\" ).replace( "'", "\\'" ) );
|
||||||
|
|
||||||
QVariantMap m = d->engine->mainFrame()->evaluateJavaScript( eval ).toMap();
|
QVariantMap m = d->engine->mainFrame()->evaluateJavaScript( eval ).toMap();
|
||||||
if ( m.isEmpty() )
|
if ( m.isEmpty() )
|
||||||
@@ -450,7 +450,7 @@ JSResolver::canParseUrl( const QString& url, UrlType type )
|
|||||||
if ( d->capabilities.testFlag( UrlLookup ) )
|
if ( d->capabilities.testFlag( UrlLookup ) )
|
||||||
{
|
{
|
||||||
QString eval = QString( "resolver.canParseUrl( '%1', %2 );" )
|
QString eval = QString( "resolver.canParseUrl( '%1', %2 );" )
|
||||||
.arg( QString( url ).replace( "'", "\\'" ) )
|
.arg( QString( url ).replace( "\\", "\\\\" ).replace( "'", "\\'" ) )
|
||||||
.arg( (int) type );
|
.arg( (int) type );
|
||||||
return d->engine->mainFrame()->evaluateJavaScript( eval ).toBool();
|
return d->engine->mainFrame()->evaluateJavaScript( eval ).toBool();
|
||||||
}
|
}
|
||||||
@@ -481,7 +481,7 @@ JSResolver::lookupUrl( const QString& url )
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString eval = QString( "resolver.lookupUrl( '%1' );" )
|
QString eval = QString( "resolver.lookupUrl( '%1' );" )
|
||||||
.arg( QString( url ).replace( "'", "\\'" ) );
|
.arg( QString( url ).replace( "\\", "\\\\" ).replace( "'", "\\'" ) );
|
||||||
|
|
||||||
QVariantMap m = d->engine->mainFrame()->evaluateJavaScript( eval ).toMap();
|
QVariantMap m = d->engine->mainFrame()->evaluateJavaScript( eval ).toMap();
|
||||||
if ( m.isEmpty() )
|
if ( m.isEmpty() )
|
||||||
@@ -520,10 +520,10 @@ JSResolver::resolve( const Tomahawk::query_ptr& query )
|
|||||||
if ( !query->isFullTextQuery() )
|
if ( !query->isFullTextQuery() )
|
||||||
{
|
{
|
||||||
eval = QString( RESOLVER_LEGACY_CODE2 "resolver.resolve( '%1', '%2', '%3', '%4' );" )
|
eval = QString( RESOLVER_LEGACY_CODE2 "resolver.resolve( '%1', '%2', '%3', '%4' );" )
|
||||||
.arg( query->id().replace( "'", "\\'" ) )
|
.arg( query->id().replace( "\\", "\\\\" ).replace( "'", "\\'" ) )
|
||||||
.arg( query->queryTrack()->artist().replace( "'", "\\'" ) )
|
.arg( query->queryTrack()->artist().replace( "\\", "\\\\" ).replace( "'", "\\'" ) )
|
||||||
.arg( query->queryTrack()->album().replace( "'", "\\'" ) )
|
.arg( query->queryTrack()->album().replace( "\\", "\\\\" ).replace( "'", "\\'" ) )
|
||||||
.arg( query->queryTrack()->track().replace( "'", "\\'" ) );
|
.arg( query->queryTrack()->track().replace( "\\", "\\\\" ).replace( "'", "\\'" ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -533,8 +533,8 @@ JSResolver::resolve( const Tomahawk::query_ptr& query )
|
|||||||
" resolve( '%1', '', '', '%2' );"
|
" resolve( '%1', '', '', '%2' );"
|
||||||
"}"
|
"}"
|
||||||
)
|
)
|
||||||
.arg( query->id().replace( "'", "\\'" ) )
|
.arg( query->id().replace( "\\", "\\\\" ).replace( "'", "\\'" ) )
|
||||||
.arg( query->fullTextQuery().replace( "'", "\\'" ) );
|
.arg( query->fullTextQuery().replace( "\\", "\\\\" ).replace( "'", "\\'" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantMap m = d->engine->mainFrame()->evaluateJavaScript( eval ).toMap();
|
QVariantMap m = d->engine->mainFrame()->evaluateJavaScript( eval ).toMap();
|
||||||
|
Reference in New Issue
Block a user