summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-06-19 12:34:09 (UTC)
committer llornkcor <llornkcor>2002-06-19 12:34:09 (UTC)
commitb55f69a46fd27ce26235029f702c0f3942fde68c (patch) (side-by-side diff)
tree47aa9ca1e9c80367050a93715f384eef2285e7b9
parent1d60bfb5925c5009122ae04009f8e99658436b35 (diff)
downloadopie-b55f69a46fd27ce26235029f702c0f3942fde68c.zip
opie-b55f69a46fd27ce26235029f702c0f3942fde68c.tar.gz
opie-b55f69a46fd27ce26235029f702c0f3942fde68c.tar.bz2
dont crash on malformed urls
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp79
1 files changed, 49 insertions, 30 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index 41fcb30..2323ac2 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -413,19 +413,25 @@ void PlayListWidget::writeConfig( Config& cfg ) const {
cfg.writeEntry("NumberOfFiles", noOfFiles );
}
void PlayListWidget::addToSelection( const DocLnk& lnk ) {
// qDebug("add");
- d->setDocumentUsed = FALSE;
- if ( mediaPlayerState->playlist() ) {
- if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" )
- d->selectedFiles->addToSelection( lnk );
+ if( lnk.file().find(" ",0,TRUE) != -1 || lnk.file().find("%20",0,TRUE) != -1) {
+ QMessageBox::message("Note","You are trying to play\na malformed url.");
+
+ } else {
+
+ d->setDocumentUsed = FALSE;
+ if ( mediaPlayerState->playlist() ) {
+ if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" )
+ d->selectedFiles->addToSelection( lnk );
+ }
+ else
+ mediaPlayerState->setPlaying( TRUE );
}
- else
- mediaPlayerState->setPlaying( TRUE );
}
void PlayListWidget::clearList() {
while ( first() )
d->selectedFiles->removeSelected();
@@ -843,40 +849,44 @@ void PlayListWidget::tabChanged(QWidget *widg) {
void PlayListWidget::btnPlay(bool b) {
// mediaPlayerState->setPlaying(b);
switch ( tabWidget->currentPageIndex()) {
case 0:
{
-
- mediaPlayerState->setPlaying(b);
- }
+ qDebug("here we are");
+ if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 || d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) {
+ QMessageBox::message("Note","You are trying to play\na malformed url.");
+
+ } else {
+
+ mediaPlayerState->setPlaying(b);
+ } }
break;
case 1:
{
- addToSelection( audioView->currentItem() );
- mediaPlayerState->setPlaying(b);
- d->selectedFiles->removeSelected( );
- tabWidget->setCurrentPage(1);
- d->selectedFiles->unSelect();
- insanityBool=FALSE;
-// audioView->clearSelection();
- }
+ addToSelection( audioView->currentItem() );
+ mediaPlayerState->setPlaying(b);
+ d->selectedFiles->removeSelected( );
+ tabWidget->setCurrentPage(1);
+ d->selectedFiles->unSelect();
+ insanityBool=FALSE;
+ }// audioView->clearSelection();
break;
case 2:
{
- addToSelection( videoView->currentItem() );
- mediaPlayerState->setPlaying(b);
- qApp->processEvents();
- d->selectedFiles->removeSelected( );
- tabWidget->setCurrentPage(2);
- d->selectedFiles->unSelect();
- insanityBool=FALSE;
-// videoView->clearSelection();
- }
+ addToSelection( videoView->currentItem() );
+ mediaPlayerState->setPlaying(b);
+ qApp->processEvents();
+ d->selectedFiles->removeSelected( );
+ tabWidget->setCurrentPage(2);
+ d->selectedFiles->unSelect();
+ insanityBool=FALSE;
+ }// videoView->clearSelection();
break;
};
+
}
void PlayListWidget::deletePlaylist() {
switch( QMessageBox::information( this, (tr("Remove Playlist?")),
(tr("You really want to delete\nthis playlist?")),
(tr("Yes")), (tr("No")), 0 )){
@@ -1065,15 +1075,18 @@ void PlayListWidget::openFile() {
fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
fileDlg->exec();
if( fileDlg->result() == 1 ) {
filename = fileDlg->LineEdit1->text();
// http://205.188.234.129:8030
// http://66.28.68.70:8000
- filename.replace(QRegExp("%20")," ");
-
- qDebug("Selected filename is "+filename);
+// filename.replace(QRegExp("%20")," ");
+ if(filename.find(" ",0,TRUE) != -1 || filename.find("%20",0,TRUE) != -1) {
+ QMessageBox::message("Note","Spaces in urls are not allowed.");
+ return;
+ } else {
+ qDebug("Selected filename is "+filename);
if(filename.right(3) == "m3u")
readm3u( filename);
else if(filename.right(3) == "pls")
readPls( filename);
else {
DocLnk lnk;
@@ -1091,12 +1104,13 @@ void PlayListWidget::openFile() {
qDebug("Writing doclink did not work");
d->selectedFiles->addToSelection( lnk);
// if(fileDlg2)
// delete fileDlg2;
}
}
+ }
if(fileDlg)
delete fileDlg;
}
void PlayListWidget::keyReleaseEvent( QKeyEvent *e)
{
@@ -1202,13 +1216,16 @@ void PlayListWidget::readm3u(const QString &filename) {
QTextStream t(&f);
QString s;//, first, second;
int i=0;
while ( !t.atEnd()) {
// Lview->insertLine(t.readLine(),-1);
s=t.readLine();
- if(s.find("#",0,TRUE) == -1) {
+ if(s.find(" ",0,TRUE) != -1 || s.find("%20",0,TRUE) != -1) {
+ QMessageBox::message("Note","Spaces in urls are not allowed.");
+ }
+ else if(s.find("#",0,TRUE) == -1) {
if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat
if(s.left(2) == "E:" || s.left(2) == "P:") {
s=s.right(s.length()-2);
DocLnk lnk( s );
QFileInfo f(s);
QString name = f.baseName();
@@ -1217,12 +1234,13 @@ void PlayListWidget::readm3u(const QString &filename) {
s=s.replace( QRegExp("\\"),"/");
lnk.setFile( s);
// lnk.setIcon(opieplayer/MPEGPlayer);
qDebug("add "+name);
d->selectedFiles->addToSelection( lnk);
} else { // is url
+
s.replace(QRegExp("%20")," ");
DocLnk lnk( s);
QString name = s.right( s.length() - 7);
// name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1);
lnk.setName(name);
lnk.setFile( s+"/");
@@ -1235,12 +1253,13 @@ void PlayListWidget::readm3u(const QString &filename) {
}
i++;
}
}
}
}
+ f.close();
}
void PlayListWidget::writem3u(const QString &filename) {
}