[vlc-commits] [Git][videolan/vlc][master] 3 commits: qt: medialib: ensure MRL are properly encoded

Steve Lhomme (@robUx4) gitlab at videolan.org
Fri Oct 6 18:48:32 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
a91d89c3 by Alexandre Janniaux at 2023-10-06T18:27:50+00:00
qt: medialib: ensure MRL are properly encoded

The default encoding QUrl::None maps to QUrl::PrettyDecoded, which is
not entierely specified (documentation even mention it can change over
different releases) and typically won't encode the spaces correctly.

- - - - -
6180022a by Alexandre Janniaux at 2023-10-06T18:27:50+00:00
qt: playlist_controller: ensure MRL are properly encoded

The default encoding QUrl::None maps to QUrl::PrettyDecoded, which is
not entierely specified (documentation even mention it can change over
different releases) and typically won't encode the spaces correctly.

- - - - -
67e2541b by Alexandre Janniaux at 2023-10-06T18:27:50+00:00
qt: MainInterface: decode partially encoded MRL on drop

When using drag&drop to play a media with characters that would need
encoding, especially spaces, the system will provide the correct URL to
the DropArea but Qt will encode it partially. Since we will encode it
afterwards, we can just decode it completely and forward it as-is to the
playlist controller.

Fixes dropping URL with spaces from a browser to VLC.

- - - - -


3 changed files:

- modules/gui/qt/maininterface/qml/MainInterface.qml
- modules/gui/qt/medialibrary/medialib.cpp
- modules/gui/qt/playlist/playlist_controller.cpp


Changes:

=====================================
modules/gui/qt/maininterface/qml/MainInterface.qml
=====================================
@@ -198,7 +198,12 @@ Item {
                 if (drop.hasUrls) {
 
                     for (let i = 0; i < drop.urls.length; i++)
-                        urls.push(drop.urls[i])
+                    {
+                        /* First decode the URL since we'll re-encode it
+                           afterwards, while fixing the non-encoded spaces. */
+                        let url = decodeURIComponent(drop.urls[i]);
+                        urls.push(url);
+                    }
 
                 } else if (drop.hasText) {
                     /* Browsers give content as text if you dnd the addressbar,


=====================================
modules/gui/qt/medialibrary/medialib.cpp
=====================================
@@ -100,7 +100,7 @@ static void convertMLItemToPlaylistMedias(vlc_medialibrary_t* ml, const MLItemId
 
 static void convertQUrlToPlaylistMedias(QUrl mrl, const QStringList& options, QVector<vlc::playlist::Media>& medias)
 {
-    vlc::playlist::Media media{ mrl.toString(QUrl::None), mrl.fileName(), options };
+    vlc::playlist::Media media{ mrl.toString(QUrl::FullyEncoded), mrl.fileName(), options };
     medias.push_back(media);
 }
 
@@ -217,7 +217,7 @@ void MediaLib::addAndPlay(const QString& mrl, const QStringList &options)
 
 void MediaLib::addAndPlay(const QUrl& mrl, const QStringList &options)
 {
-    vlc::playlist::Media media{ mrl.toString(QUrl::None), mrl.fileName(), options };
+    vlc::playlist::Media media{ mrl.toString(QUrl::FullyEncoded), mrl.fileName(), options };
     m_intf->p_mainPlaylistController->append( QVector<vlc::playlist::Media>{media}, true );
 }
 


=====================================
modules/gui/qt/playlist/playlist_controller.cpp
=====================================
@@ -79,7 +79,7 @@ QVector<Media> toMediaList(const QVariantList &sources)
             if (mrl.isLocalFile())
                 mrl = resolveWinSymlinks(mrl);
 
-            return Media(mrl.toString(QUrl::None), mrl.fileName());
+            return Media(mrl.toString(QUrl::FullyEncoded), mrl.fileName());
         } else if (value.canConvert<SharedInputItem>())
         {
             return Media(value.value<SharedInputItem>().get());



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/115fb69e2e79877b6a237b92266fe9a0aa6b1049...67e2541b19b8a12f6d799222872dd0f0ac2e83b4

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/115fb69e2e79877b6a237b92266fe9a0aa6b1049...67e2541b19b8a12f6d799222872dd0f0ac2e83b4
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list