Skip to content

Commit

Permalink
Limited links with file:/// only
Browse files Browse the repository at this point in the history
  • Loading branch information
Eswcvlad committed May 19, 2015
1 parent 0ab902e commit 204d84a
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion xspf2lnk/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ private void _playlistWorker_DoWork(object sender, DoWorkEventArgs e)
// Getting all tracks as a collection
var trackList = playlist.SelectNodes("//xspf:track", nsManager);

if (trackList == null)
return;

// Setting the progress bar value to correspond to the track count
_operationProgressBar.Invoke((MethodInvoker) delegate { _operationProgressBar.Maximum = trackList.Count; });

Expand All @@ -106,7 +109,16 @@ private void _playlistWorker_DoWork(object sender, DoWorkEventArgs e)
return;
}

var filePath = new Uri(track["location"].InnerText).LocalPath;
var locationElement = track["location"];
// Skip non-valid and non-local entries
// That also skips relative paths
if (locationElement == null || !locationElement.InnerText.StartsWith("file:///"))
{
_playlistWorker.ReportProgress(0, "Skipped");
continue;
}

var filePath = new Uri(locationElement.InnerText).LocalPath;
var fileName = Path.GetFileName(filePath);
var linkAddress = new StringBuilder(_selectFolderTextBox.Text);

Expand Down

0 comments on commit 204d84a

Please sign in to comment.