Skip to content

Commit

Permalink
Remove question mark and any extra data after it, if present. efserve…
Browse files Browse the repository at this point in the history
…rs.com uses that space for server name and map information.
  • Loading branch information
stefansundin committed May 31, 2023
1 parent 3c7fe6b commit d24ff2a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions linux/stvef-protocol
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,15 @@ else
exit 1
fi

# Remove extra data
if [[ "$arg" == *"?"* ]]; then
arg="${arg%\?*}"
fi

if [[ "$arg" == "connect/"* ]]; then
SERVER="${arg:8}"
else
# Legacy format
# Example arg: 74.91.116.133;27961;BeerGardenSuperFFAv;hm_noon;0;
IFS=';' read -r SERVER_IP SERVER_PORT SERVER_NAME MAP_NAME REST <<< "$arg"
SERVER="$SERVER_IP:$SERVER_PORT"
Expand Down
7 changes: 7 additions & 0 deletions mac/stvef-protocol.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,20 @@ - (void)handleAppleEvent:(NSAppleEventDescriptor *)event withReplyEvent: (NSAppl
return;
}

// Remove extra data
if ([arg containsString:@"?"]) {
NSRange questionMark = [arg rangeOfString:@"?"];
arg = [arg substringToIndex:questionMark.location];
}

// Parse arg
// TODO: Maybe validate the input a bit better
NSString *server;
if ([arg hasPrefix:@"connect/"]) {
server = [arg substringFromIndex:8];
}
else {
// Legacy format
NSArray *args = [arg componentsSeparatedByString:@";"];
server = [NSString stringWithFormat: @"%@:%@", args[0], args[1]];
}
Expand Down

0 comments on commit d24ff2a

Please sign in to comment.