Skip to content

Fix incoming webhook file extension detection - #2402

Open
mysubcult wants to merge 1 commit into
LiveHelperChat:masterfrom
mysubcult:fix-incoming-webhook-file-extension-20260807
Open

Fix incoming webhook file extension detection#2402
mysubcult wants to merge 1 commit into
LiveHelperChat:masterfrom
mysubcult:fix-incoming-webhook-file-extension-20260807

Conversation

@mysubcult

@mysubcult mysubcult commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Use the provided upload filename extension when the remote file URL has no valid extension.
  • Normalize the stored MIME type from the resolved extension using the existing LHC extension/MIME map, so download validation remains consistent.

Why

Some integrations expose media through generic endpoints such as /ru/getfile while also providing the real filename, for example NISSAN.rar. In that case LHC can derive an invalid extension from the URL and later reject the file during download because extension and MIME do not match.

Testing

  • php -l lhc_web/lib/core/lhchat/lhchatwebhookincomming.php
  • Verified that an affected production file downloads as attachment filename 8610-NISSAN.rar.

@mysubcult mysubcult changed the title Fix incoming webhook file extension detection Fix incoming webhook file extension and size validation Aug 7, 2026

@remdex remdex left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read comments...

}
}

public static function getExtensionByMime($mimeType, $getMime = false) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's the only changes required in that function everything else is not related... Because if that pull request won't be accepted.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated. I removed the changes from getExtensionByMime() and narrowed the PR to the incoming webhook file extension handling only. It now uses the existing extension/MIME map and the filename provided by the webhook, without adding MIME aliases.

@mysubcult
mysubcult force-pushed the fix-incoming-webhook-file-extension-20260807 branch from c140229 to acb0b52 Compare August 7, 2026 10:19
@mysubcult mysubcult changed the title Fix incoming webhook file extension and size validation Fix incoming webhook file validation Aug 7, 2026
@mysubcult
mysubcult force-pushed the fix-incoming-webhook-file-extension-20260807 branch 2 times, most recently from 79f508a to b025870 Compare August 7, 2026 10:21
@mysubcult mysubcult changed the title Fix incoming webhook file validation Fix incoming webhook file extension detection Aug 7, 2026
@mysubcult
mysubcult force-pushed the fix-incoming-webhook-file-extension-20260807 branch from b025870 to e07b6a6 Compare August 7, 2026 10:22
@mysubcult
mysubcult requested a review from remdex August 7, 2026 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants