Skip to content

Commit

Permalink
Exercise parsers: fixed filename issue when opening files with spaces…
Browse files Browse the repository at this point in the history
… or umlauts
  • Loading branch information
ssaring committed Jul 9, 2023
1 parent d6afbbb commit d95b176
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 7 deletions.
2 changes: 2 additions & 0 deletions sportstracker/docs/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ v8.0.0:
ExerciseViewer changes:
- Garmin FIT parser: bugfix for handling laps without any speed data
(when the lap contains just a break without any activity)
- All XML-based parsers (GPX, TCX, Polar): fixed error when opening files with
spaces or special characters in the filename

v7.9.1:
Project changes:
Expand Down
3 changes: 0 additions & 3 deletions sportstracker/docs/TODO.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
SportsTracker-TODO
==================

Bug: exception when opening or importing HRM files with "Umlauts" in the pathname (at least in macOS):
- java.net.MalformedURLException: no protocol: /Users/stefan/Desktop/Jörg/2023-06-30 Rambin.gpx

Remove all interfaces which are not really needed and don't provide advantages (e.g. STDocument etc.)

ExerciseViewer standalone mode:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ class GarminTcxParser : AbstractExerciseParser() {
fun parseExercise(filename: String): EVExercise {

try {
val document = SAXBuilder().build(filename)
// create a File of the filename string to avoid URL problems when filename contains spaces or umlauts
val document = SAXBuilder().build(java.io.File(filename))
return parseExerciseElement(document.rootElement)
}
catch (e: Exception) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ class PolarPedParser : AbstractExerciseParser() {

private fun readPedFile(filename: String): Element {
try {
val document = SAXBuilder().build(filename)
// create a File of the filename string to avoid URL problems when filename contains spaces or umlauts
val document = SAXBuilder().build(java.io.File(filename))
return document.rootElement
} catch (e: Exception) {
throw EVException("Failed to parse the Polar Personal Trainer exercise file '$filename' ...", e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ class PolarRS200SDParser : AbstractExerciseParser() {
fun parseExercise(filename: String): EVExercise {

try {
val document = SAXBuilder().build(filename)
// create a File of the filename string to avoid URL problems when filename contains spaces or umlauts
val document = SAXBuilder().build(java.io.File(filename))
return parseExerciseElement(document.rootElement)
}
catch (e: Exception) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ class TopoGrafixGpxParser : AbstractExerciseParser() {
fun parseExercise(filename: String): EVExercise {

try {
val document = SAXBuilder().build(filename)
// create a File of the filename string to avoid URL problems when filename contains spaces or umlauts
val document = SAXBuilder().build(java.io.File(filename))
return parseExerciseElement(document.rootElement)
}
catch (e: Exception) {
Expand Down

0 comments on commit d95b176

Please sign in to comment.