Commit 91c030f3 authored by Luke Bratch's avatar Luke Bratch

Use a space followed by a colon to determine the final parameter in extractfinalparameter().

This fixes the topic being stored incorrectly when the setter's host is a raw IPv6 address.
parent 4b282dd6
......@@ -16,6 +16,4 @@ Ability to load new certificate whilst running.
Are any other strncmps incorrect (i.e. just checking a substring)?
Topic is stored incorrectly when the setter's host was an IPv6 address (colon search issue?).
Crash when requesting 30 hour replay.
......@@ -213,15 +213,19 @@ void stripprefix(char *string, int debug) {
}
// Extract final parameter from IRC message, removing the leading colon ':'
// e.g. given this string:
// ":irc.tghost.co.uk 332 blabounce #test :This is a test topic!"
// e.g. given either of these strings:
// ":irc.tghost.co.uk 332 blabounce #test :foo:bar topic!"
// ":nick!user@fe80:1:2:3:5:6:7:8 TOPIC #test :foo:bar topic!"
// We want to end up with:
// "This is a test topic!"
// "foo:bar topic!"
void extractfinalparameter(char *string) {
// The method used is to look for the first space (" ") followed by a colon (":")
// and take everything after that colon as the final parameter.
// Make a copy to work with
char string2[strlen(string)];
// Position of colon
// Position of final parameter's leading colon
int colonpos = -1;
debugprint(DEBUG_FULL, "extractfinalparameter(): starting with '%s', strlen: %zd.\n", string, strlen(string));
......@@ -229,17 +233,20 @@ void extractfinalparameter(char *string) {
// Strip the colon at position 0 if there is one
stripprefix(string, 1);
// Find the colon
// Look for spaces...
for (size_t i = 0; i < strlen(string); i++) {
if (string[i] == ':') {
debugprint(DEBUG_FULL, "Found colon at position %zd!\n", i);
colonpos = i;
break;
if (string[i] == ' ') {
debugprint(DEBUG_FULL, "extractfinalparameter(): found space at position %zd! Checking for colon...\n", i);
// ...and check if the next character is a colon
if (string[i + 1] == ':') {
colonpos = i + 1;
break;
}
}
}
if (colonpos == -1) {
debugprint(DEBUG_FULL, "no colon found, returning\n");
debugprint(DEBUG_SOME, "extractfinalparameter(): no space followed by a colon found, returning.\n");
return;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment