Skip to content

Commit

Permalink
Added support for escaped semicolons in configuration files
Browse files Browse the repository at this point in the history
  • Loading branch information
meetecho committed Sep 9, 2014
1 parent 9dafd22 commit e4adcb7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
27 changes: 25 additions & 2 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,31 @@ janus_config *janus_config_parse(const char *config_file) {
janus_config_destroy(jc);
return NULL;
}
if((c = strrchr(temp, ';')) != NULL)
*c = '\0';
/* Strip comments from the value */
char *sc = temp;
while((c = strchr(sc, ';')) != NULL) {
if(c == temp) {
/* Comment starts here */
*c = '\0';
break;
}
c--;
if(*c != '\\') {
/* Comment starts here */
*c = '\0';
break;
}
/* Escaped semicolon, remove the slash */
sc = c;
int len = strlen(temp)-(sc-temp), pos = 0;
for(pos = 0; pos < len; pos++)
sc[pos] = sc[pos+1];
sc[len-1] = '\0';
if(len == 2)
break;
/* Go on */
sc++;
}
value = trim(temp);
janus_config_item *nci = calloc(1, sizeof(janus_config_item));
if(nci == NULL) {
Expand Down
1 change: 1 addition & 0 deletions janus.c
Original file line number Diff line number Diff line change
Expand Up @@ -3179,6 +3179,7 @@ gint main(int argc, char *argv[])

/* Prepare a summary on the gateway */
json_t *info = json_object();
json_object_set_new(info, "janus", json_string("server_info"));
json_object_set_new(info, "name", json_string(JANUS_NAME));
json_object_set_new(info, "version", json_integer(JANUS_VERSION));
json_object_set_new(info, "version_string", json_string(JANUS_VERSION_STRING));
Expand Down

0 comments on commit e4adcb7

Please sign in to comment.