[Asterisk-code-review] res_musiconhold: Added check for dot character in path of playlist en... (asterisk[16])

Friendly Automation asteriskteam at digium.com
Wed May 20 07:18:35 CDT 2020


Friendly Automation has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/14407 )

Change subject: res_musiconhold: Added check for dot character in path of playlist entries to avoid warnings
......................................................................

res_musiconhold: Added check for dot character in path of playlist entries to avoid warnings

A warning was triggered that there may be a problem regarding file
extension (which is correct and should not be set anyway). The warning
also appeared if there was dot within the path itself.

E.g.
[sales-queue-hold]
mode=playlist
entry=/var/www/domain.tld/moh/funky_music

The music played correctly but you get a warning message.

Now there will be a check if the position of a potential dot character
is after the last position of a slash character. This dot charachter
will be treated as a extension naming. Dots within the path then ignored.

ASTERISK-28892
Reported-By: Nicholas John Koch

Change-Id: I2ec35a613413affbf5fcc01c8c181eba24865b9e
---
M res/res_musiconhold.c
1 file changed, 8 insertions(+), 3 deletions(-)

Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  Kevin Harwell: Looks good to me, but someone else must approve
  Sean Bright: Looks good to me, approved
  Friendly Automation: Approved for Submit



diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c
index dd9b8a5..01a14b9 100644
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -1087,9 +1087,14 @@
 				if (!dup) {
 					continue;
 				}
-				if (ast_begins_with(dup, "/") && strrchr(dup, '.')) {
-					ast_log(LOG_WARNING, "The playlist entry '%s' may include an extension, which could prevent it from playing.\n",
-						dup);
+
+				if (ast_begins_with(dup, "/")) {
+					char *last_pos_dot = strrchr(dup, '.');
+					char *last_pos_slash = strrchr(dup, '/');
+					if (last_pos_dot && last_pos_dot > last_pos_slash) {
+						ast_log(LOG_WARNING, "The playlist entry '%s' may include an extension, which could prevent it from playing.\n",
+							dup);
+					}
 				}
 				AST_VECTOR_APPEND(&mohclass->files, dup);
 			} else {

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/14407
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: I2ec35a613413affbf5fcc01c8c181eba24865b9e
Gerrit-Change-Number: 14407
Gerrit-PatchSet: 3
Gerrit-Owner: Nicholas John Koch <koch at njk-it.de>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Sean Bright <sean.bright at gmail.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200520/65144ee8/attachment-0001.html>


More information about the asterisk-code-review mailing list