[vlc-devel] [PATCH] gui: Replace all spaces with "%20" in URLs

Jan Scheers jan.scheers at gmail.com
Wed Dec 21 18:26:58 CET 2011


fix #3435

---
 modules/gui/macosx/open.m                  |    1 +
 modules/gui/qt4/components/open_panels.cpp |   22 ++++++----------------
 modules/gui/qt4/components/open_panels.hpp |    9 ---------
 3 files changed, 7 insertions(+), 25 deletions(-)

diff --git a/modules/gui/macosx/open.m b/modules/gui/macosx/open.m
index 5c5fb0c..df8368f 100644
--- a/modules/gui/macosx/open.m
+++ b/modules/gui/macosx/open.m
@@ -1040,6 +1040,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
     else
     {
         o_mrl_string = [o_net_http_url stringValue];
+        o_mrl_string = [o_mrl_string stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
     }
     [self setMRL: o_mrl_string];
 }
diff --git a/modules/gui/qt4/components/open_panels.cpp b/modules/gui/qt4/components/open_panels.cpp
index 78bb4b7..6a1f77d 100644
--- a/modules/gui/qt4/components/open_panels.cpp
+++ b/modules/gui/qt4/components/open_panels.cpp
@@ -601,8 +601,6 @@ NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
     else
         b_recentList = false;
 
-    /* Use a simple validator for URLs */
-    ui.urlComboBox->setValidator( new UrlValidator( this ) );
     ui.urlComboBox->setFocus();
 }
 
@@ -642,6 +640,12 @@ void NetOpenPanel::updateMRL()
 {
     QString url = ui.urlComboBox->lineEdit()->text();
 
+    int i;
+    while( (i = url.indexOf( ' ' )) != -1 )
+    {
+        url.replace( i, 1, "%20" );
+    };
+
     if( url.isEmpty() )
         return;
 
@@ -652,20 +656,6 @@ void NetOpenPanel::updateMRL()
     emit mrlUpdated( qsl, "" );
 }
 
-QValidator::State UrlValidator::validate( QString& str, int& ) const
-{
-    if( str.contains( ' ' ) )
-        return QValidator::Invalid;
-    if( !str.contains( "://" ) )
-        return QValidator::Intermediate;
-    return QValidator::Acceptable;
-}
-
-void UrlValidator::fixup( QString& str ) const
-{
-    str = str.trimmed();
-}
-
 /**************************************************************************
  * Open Capture device ( DVB, PVR, V4L, and similar )                     *
  **************************************************************************/
diff --git a/modules/gui/qt4/components/open_panels.hpp b/modules/gui/qt4/components/open_panels.hpp
index 85257ce..0f7c216 100644
--- a/modules/gui/qt4/components/open_panels.hpp
+++ b/modules/gui/qt4/components/open_panels.hpp
@@ -149,15 +149,6 @@ public slots:
     virtual void updateMRL();
 };
 
-class UrlValidator : public QValidator
-{
-   Q_OBJECT
-public:
-   UrlValidator( QObject *parent ) : QValidator( parent ) { }
-   void fixup( QString& ) const;
-   QValidator::State validate( QString&, int& ) const;
-};
-
 class DiscOpenPanel: public OpenPanel
 {
     Q_OBJECT
-- 
1.7.8




More information about the vlc-devel mailing list