[Asterisk-code-review] res_musiconhold: Added check for dot character in path of playlist en... (asterisk[16])
Nicholas John Koch
asteriskteam at digium.com
Wed May 13 13:55:08 CDT 2020
Nicholas John Koch has uploaded this change for review. ( 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, 10 insertions(+), 3 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/07/14407/1
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c
index dd9b8a5..c2eb1ac 100644
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -1087,9 +1087,16 @@
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 != NULL) {
+ if ((int)(last_pos_dot - dup) > (int)(last_pos_slash - dup)) {
+ 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: 1
Gerrit-Owner: Nicholas John Koch <koch at njk-it.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200513/b6ee2b7f/attachment.html>
More information about the asterisk-code-review
mailing list