-
Notifications
You must be signed in to change notification settings - Fork 181
Playlist multi add - pre selection of selected lists #4026
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -186,6 +186,33 @@ class PlaylistDataManager { | |
| return exists | ||
| } | ||
|
|
||
| func manualPlaylistUUIDs(for episodesUUIDs: [String], dbQueue: PCDBQueue) -> [String] { | ||
| var uuids: [String] = [] | ||
| let episodesUUIDsString = DataHelper.convertArrayToInString(episodesUUIDs) | ||
| dbQueue.read { db in | ||
| do { | ||
| let query = """ | ||
| SELECT playlist_uuid | ||
| FROM \(DataManager.playlistEpisodeTableName) | ||
| WHERE episodeUuid IN (\(episodesUUIDsString)) | ||
| GROUP BY playlist_uuid | ||
| HAVING COUNT(DISTINCT episodeUuid) = \(episodesUUIDs.count) | ||
| """ | ||
| let resultSet = try db.executeQuery(query, values: []) | ||
| defer { resultSet.close() } | ||
|
|
||
| while resultSet.next() { | ||
| if let uuid = resultSet.string(forColumn: "playlist_uuid") { | ||
| uuids.append(uuid) | ||
| } | ||
| } | ||
| } catch { | ||
| FileLog.shared.addMessage("PlaylistDataManager.manualPlaylistUUIDs error: \(error)") | ||
| } | ||
| } | ||
| return uuids | ||
| } | ||
|
Comment on lines
+189
to
+214
|
||
|
|
||
| func manualPlaylistUUIDs(for episodeUUID: String, dbQueue: PCDBQueue) -> [String] { | ||
| var uuids: [String] = [] | ||
| dbQueue.read { db in | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
manualPlaylistUUIDs(for episodesUUIDs: [String])builds a SQLINclause by interpolating the result ofDataHelper.convertArrayToInString(episodesUUIDs)directly into the query string, which is vulnerable to SQL injection if anyepisodeUuidcontains quotes or SQL metacharacters. Sinceepisode.uuidvalues are populated from server JSON (episodeJson["uuid"]) and then passed here (e.g. viaepisodes.map { $0.uuid }), an attacker controlling server responses or intercepting traffic could inject arbitrary SQL and read or modify data in the local database. Instead of string-concatenating theINlist, construct the query using?placeholders for each UUID and pass the episode UUIDs via thevaluesarray so the database layer performs proper escaping/binding.