fix(album): restore empty album import interaction - #776
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR restores interactivity of the empty album import area by adding a DropArea over the album default page for drag-and-drop imports and adjusting z-ordering so the import UI remains clickable and visible. Sequence diagram for empty album drag-and-drop import interactionsequenceDiagram
actor User
participant AlbumDefaultPage
participant DropArea
participant Presenter
User->>AlbumDefaultPage: drag files over empty album area
AlbumDefaultPage->>DropArea: detect drop event
DropArea->>DropArea: onDropped(drop)
DropArea->>Presenter: importMetas(list, album)
Presenter-->>User: album imports processed
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
1b982c4 to
0542748
Compare
deepin pr auto review★ 总体评分:55分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 --- a/src/music-player/albumlist/AlbumDefaultPage.qml
+++ b/src/music-player/albumlist/AlbumDefaultPage.qml
@@ -17,43 +17,47 @@ Rectangle {
property var supportedAudioSuffixes: [
"aac", "ac3", "aiff", "amr", "ape", "flac", "m4a",
"mp3", "ogg", "opus", "voc", "wav", "wma"
]
+ property var safeSuffixPattern: {
+ var escaped = supportedAudioSuffixes.map(function(s) {
+ return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
+ });
+ return new RegExp("\\.(" + escaped.join("|") + ")$", "i");
+ }
color: Qt.rgba(0, 0, 0, 0)
- function isSupportedAudioFile(fileName) {
- var suffixPattern = new RegExp("\\.(" + supportedAudioSuffixes.join("|") + ")$", "i")
- return suffixPattern.test(fileName)
- }
-
function safeImportUrl(rawUrl) {
var value = rawUrl.toString()
var schemeMatch = value.match(/^([a-z][a-z0-9+.-]*):/i)
var scheme = schemeMatch ? schemeMatch[1].toLowerCase() : ""
- if (scheme === "data" || scheme === "javascript" || scheme === "qrc")
+ // 采用白名单机制,仅允许本地文件协议或无协议的相对路径
+ if (scheme !== "" && scheme !== "file")
return ""
var decodedValue = value
try {
var prevValue = ""
while (prevValue !== decodedValue) {
prevValue = decodedValue
decodedValue = decodeURIComponent(decodedValue)
}
} catch (error) {
return ""
}
if (/(^|\/)\.\.(\/|$)/.test(decodedValue))
return ""
var path = decodedValue.split(/[?#]/)[0]
- if (path.endsWith("/"))
- return value
var fileName = path.substring(path.lastIndexOf("/") + 1)
- if (!isSupportedAudioFile(fileName))
+ if (fileName === "" || !safeSuffixPattern.test(fileName))
return ""
return value
} |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: wyu71 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Keep the empty album import area interactive without covering its controls.
修复空专辑页面导入区域覆盖控件导致无法点击的问题。
Log: 修复专辑空页面导入
PMS: BUG-374225
Influence: 空专辑页面可以正常点击导入并支持拖入歌曲。
Summary by Sourcery
Restore empty album import interactions while safely filtering dropped file URLs.
New Features:
Bug Fixes: