Fixed Fix detection of Opus audio files with .opus instead of .ogg extension

Steffen

Well-known member
Affected version
2.2.7
Opus audio files can be uploaded (and rendered as an audio player) when they have a ".ogg" extension. XenForo doesn't recognize them when they have the recommended ".opus" extension (https://en.wikipedia.org/wiki/Opus_(audio_format)). This is easy to fix. :)

Diff:
diff --git a/src/XF/App.php b/src/XF/App.php
index 51395a939..7cf644589 100644
--- a/src/XF/App.php
+++ b/src/XF/App.php
@@ -349,6 +349,7 @@ class App implements \ArrayAccess
             return [
                 'mp3' => 'audio/mpeg',
                 'ogg' => 'audio/ogg',
+                'opus' => 'audio/ogg',
                 'wav' => 'audio/wav',
             ];
         };

Opus has universal browser support: https://caniuse.com/opus
 
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.2.8).

Change log:
Add .opus as a supported audio file extension
There may be a delay before changes are rolled out to the XenForo Community.
 
Has this been implemented? When I attach a file with the .opus extension to a post, the extension gets changed to .ogg during the process. If I then download the .ogg file, it still plays back as Opus. So it seems that XF automatically encapsulates Opus files in the Ogg container. Why does this happen, and can it be avoided? We use Opus files as digital products, and changing their extensions is very misleading.

Does it have to do with the missing 'audio/opus' for 'opus' in the @Steffen’s snippet above?
 
Last edited:
Has this been implemented? When I attach a file with the .opus extension to a post, the extension gets changed to .ogg during the process. If I then download the .ogg file, it still plays back as Opus. So it seems that XF automatically encapsulates Opus files in the Ogg container. Why does this happen, and can it be avoided? We use Opus files as digital products, and changing their extensions is very misleading.

Does it have to do with the missing 'audio/opus' for 'opus' in the @Steffen’s snippet above?
It says it was implemented in 2.2.8 which was quite a while ago. If you're on a current release (2.3), best to open a new bug report since this one is closed. If you're on a version of 2.2 prior to 2.2.8, then you need to upgrade to get the fix.
 
It says it was implemented in 2.2.8 which was quite a while ago. If you're on a current release (2.3), best to open a new bug report since this one is closed. If you're on a version of 2.2 prior to 2.2.8, then you need to upgrade to get the fix.
The issue is present on this forum.
 
Then do a new bug report. Old bug reports that are closed as Fixed aren't monitored.
I believe it would be more convenient for all the parties involved to reopen this bug report rather than create a new one. That way, we can keep all relevant information consolidated in one place.
 
See:
 
Has this been implemented?
Yes, this was implementend and thus the reported bug has been fixed.
If this wasn't fixed, XenForo wouldn't accept .opus files as audio.

When I attach a file with the .opus extension to a post, the extension gets changed to .ogg during the process.
Yes, but this is a different issue.
It is somewhat related to this bug report, but nonetheless a different issue.

So it seems that XF automatically encapsulates Opus files in the Ogg container.
Most likely not.
 
Last edited:
If thias wasn't fixed, XenForo wouldn't accept .opus files as audio.
In fact, it seems that .opus files are not accepted outside the scope of the audio player.

I have DragonByte eCommerce installed, and the .opus extension has been added under ACP > Options > Attachments > Allowed attachment file extensions. However, I’m unable to attach files with the .opus extension as attachment-based downloads in DragonByte eCommerce.

This may be a fault of DragonByte eCommerce, but it could also originate from XenForo itself. The issue is currently being investigated.
 
In fact, it seems that .opus files are not accepted outside the scope of the audio player.
I am not sure what this is supposed to mean, but XenForo accepts .opus files that are ogg containers (it would not accept a text file renamed to .opus) as audio if video / audio uploads are enabled:
1758050499645.webp

If video / audio uploads are not allowed, .opus files that are ogg containers will not be accepted, even if you add .opus to Allowed attachment file extensions.

Why is that the case?
Because video / audio are not allowed and the file is still ... audio.
If you instead tried to upload a text file renamed to .opus and audio / video uploads are not allowed, this would work (as it would be treated as opaque binary content and not detected as audio).
 
I am not sure what this is supposed to mean […]
I meant “any part of the XF application where the use of the audio player is not expected.” For instance, a forum post in the frontend is a context where the audio player can be used, whereas the ACP is not intended for such use.

XenForo accepts .opus files that are ogg containers […]
1) I have checked “Allow video/audio uploads with maximum file size” in ACP > Options > Attachments.

2) I have added “opus” in ACP > Options > Attachments > Allowed attachment file extensions.

3) If I try to upoad an Opus file in ACP > DragonByte eCommerce > Digital products > Downloads, I get the following error:

1758096541274.webp

which is paradoxical because it begins by stating that the uploaded file’s extension is not allowed, and ends by listing it as allowed.

With these same settings, I can still upload .opus files as attachments in the front end, although their extensions are changed to .ogg in the process.

As a result, I’m trying to sort out a twofold problem with .opus—one that’s certainly caused by XF and may or may not be partly caused by eCommerce.
 
which is paradoxical because it begins by stating that the uploaded file’s extension is not allowed, and ends by listing it as allowed.
Not at all.

I don't know the Add-on, but judging from the screenshot it doesn't seem to opt-in for video / audio uploads so only handles what is configured for Allowed attachment file extensions (or maybe it has its own setting?).

.ogg isn't on the list of allowed extensions so your .opus file (which ends up as .ogg due to it being detected as an ogg container and the extension changed to .ogg) is rejected.

If you add .ogg to Allowed attachment file extensions it will most likely work (if the filesize doesn't exceed Maximum attachment file size)
 
Back
Top Bottom