Can't import OPML with .opml extension #87

Open
opened 2021-07-29 16:09:55 +00:00 by Darkyenus · 3 comments
Darkyenus commented 2021-07-29 16:09:55 +00:00 (Migrated from github.com)

Describe the bug
Some podcast players export OPML files with .opml extension, but such file cannot be chosen in the "Import OPML" dialog. After I renamed the file to have .xml extension, the import worked fine. Wikipedia even lists .opml as the main file extension.

To Reproduce

  1. Get OPML file with .opml extension - in my case the file was named subscriptions.opml and was generated by Castro on iOS.
  2. Attempt to load the file in Escapepod through "Settings cog" -> "Import OPML" - not possible, the file is grayed out

Expected behavior
.opml file extension should be accepted by the file chooser dialog.

Screenshots
image

Device:

  • Device: Google Pixel 4a
  • OS: Graphene OS 2021.07.26.20
  • App Version: 1.0.4 (latest on F-Droid as of time of writing)

Additional context
Other podcast players imported this file just fine (Tsacdop, Podverse and AntennaPod, all from F-Droid).

**Describe the bug** Some podcast players export OPML files with `.opml` extension, but such file cannot be chosen in the "Import OPML" dialog. After I renamed the file to have `.xml` extension, the import worked fine. [Wikipedia even lists `.opml` as the main file extension.](https://en.wikipedia.org/wiki/OPML) **To Reproduce** 1. Get OPML file with `.opml` extension - in my case the file was named `subscriptions.opml` and was generated by [Castro](https://www.castro.fm/) on iOS. 2. Attempt to load the file in Escapepod through "Settings cog" -> "Import OPML" - not possible, the file is grayed out **Expected behavior** `.opml` file extension should be accepted by the file chooser dialog. **Screenshots** ![image](https://user-images.githubusercontent.com/5280068/127526046-d506c1b7-b717-4ed1-a8cb-23cb0b3265c2.png) **Device:** - Device: Google Pixel 4a - OS: Graphene OS 2021.07.26.20 - App Version: 1.0.4 (latest on F-Droid as of time of writing) **Additional context** Other podcast players imported this file just fine (Tsacdop, Podverse and AntennaPod, all from F-Droid).
y20k commented 2021-07-30 12:14:16 +00:00 (Migrated from github.com)

Hi @Darkyenus

Escapepod starts the file picker with a mime type filter. The filter is set to "text/xml" at the moment. Reading your bug report I was considering to widen the filter to "text/*" (all text file types).

For testing purposes I created a text file with OPML data, saved it as "feeds.opml", and uploaded it to my phone. The system file browser categorizes the file with an .opml extension as a binary file.

With a filter set to "text/*" one would still not be able to open .opml files.

file_picker

I am a bit hesitant to open the filter to include binary files. I need to check if I can whitelist the .opml file extension.

May I ask as what kind of file the opml file from Castro is identified on your phone - also BIN or TXT or ...

Hi @Darkyenus Escapepod starts the file picker with a mime type filter. The filter is set to "text/xml" at the moment. Reading your bug report I was considering to widen the filter to "text/*" (all text file types). For testing purposes I created a text file with OPML data, saved it as "feeds.opml", and uploaded it to my phone. The system file browser categorizes the file with an .opml extension as a binary file. With a filter set to "text/*" one would still not be able to open .opml files. ![file_picker](https://user-images.githubusercontent.com/9103935/127651005-11393986-c6ec-49ae-ac29-73433d1bc1f4.png) I am a bit hesitant to open the filter to include binary files. I need to check if I can whitelist the .opml file extension. ❓ May I ask as what kind of file the opml file from Castro is identified on your phone - also BIN or TXT or ... ❓
Darkyenus commented 2021-07-30 20:05:10 +00:00 (Migrated from github.com)

It is classified as a BIN file, like in your screenshot.

By the way, it looks like AntennaPod (at least, I have uninstalled others already) just accepts any file and then shows an error message (a pretty ugly one) when parsing fails. Which, if it isn't possible to specify the filter through an extension or differently, might be a better way to go about this. The current way (text/xml) isn't bulletproof either, not all XMLs are OPML files, so it shouldn't be a significant problem.

Alternatively, you could specify multiple MIME types and only allow text/xml and whatever MIME type is assigned to opml files (should be one of application/xml, text/xml or text/x-opml, but will probably be a generic binary MIME type, like application/octet-stream or just application/*). If it was my call, I'd allow just text/xml, text/x-opml and application/*. It wouldn't be perfect, but it would prevent the most obivous errors (like choosing a photo or something) and it would probably work no matter what MIME Android thinks .opmls are.

It is classified as a BIN file, like in your screenshot. By the way, it looks like AntennaPod (at least, I have uninstalled others already) just accepts any file and then shows an error message (a pretty ugly one) when parsing fails. Which, if it isn't possible to specify the filter through an extension or differently, might be a better way to go about this. The current way (`text/xml`) isn't bulletproof either, not all XMLs are OPML files, so it shouldn't be a significant problem. Alternatively, you could [specify multiple MIME types](https://developer.android.com/guide/components/intents-common.html#OpenFile) and only allow `text/xml` and whatever MIME type is assigned to opml files ([should be](https://en.wikipedia.org/wiki/OPML) one of `application/xml`, `text/xml` or `text/x-opml`, but will probably be a generic binary MIME type, like `application/octet-stream` or just `application/*`). If it was my call, I'd allow just `text/xml`, `text/x-opml` and `application/*`. It wouldn't be perfect, but it would prevent the most obivous errors (like choosing a photo or something) and it would probably work no matter what MIME Android thinks `.opml`s are.

Just a note: Escapepod currently supports the import of OPML files of the type application/xml, text/xml and text/x-opml (see Keys.kt).

Just a note: Escapepod currently supports the [import](https://codeberg.org/y20k/escapepod/src/commit/268348b72b8e56258aed39a4fc0af30dcdcf2698/app/src/main/java/org/y20k/escapepod/SettingsFragment.kt#L359) of OPML files of the type `application/xml`, `text/xml` and `text/x-opml` (see [Keys.kt](https://codeberg.org/y20k/escapepod/src/branch/master/app/src/main/java/org/y20k/escapepod/Keys.kt#L140)).
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: y20k/escapepod#87
There is no content yet.