mirror of
https://github.com/barronwaffles/dwc_network_server_emulator.git
synced 2026-08-27 05:14:31 -05:00
Fix edge case in backend server query parser
(game_match_type = '0817') where game_match_type was interpreted as an integer resulting in a false int == string comparison.
This commit is contained in:
@@ -289,6 +289,28 @@ class GameSpyBackendServer(object):
|
||||
# dwc_test = 'test', dwc_test2 = dwc_test, dwc_test3 = dwc_test2
|
||||
token = '"' + token + '"'
|
||||
|
||||
elif token_type == TokenType.NUMBER:
|
||||
for idx2 in range(idx + 1, len(translated)):
|
||||
_, _, token_type = self.get_token(translated[idx2])
|
||||
|
||||
if token_type == TokenType.TOKEN and translated[idx2] not in ('(', ')'):
|
||||
if idx2 == idx + 1:
|
||||
# Skip boolean operator if it's the first token on the right
|
||||
continue
|
||||
|
||||
# Boolean operator, leave left as integer
|
||||
token = str(int(token))
|
||||
break
|
||||
|
||||
elif token_type == TokenType.STRING or token_type == TokenType.NUMBER:
|
||||
if token_type == TokenType.STRING:
|
||||
# Found string on far right, turn left into string as well
|
||||
token = "'" + token + "'"
|
||||
elif token_type == TokenType.NUMBER:
|
||||
token = str(int(token))
|
||||
break
|
||||
|
||||
|
||||
translated[idx] = token
|
||||
|
||||
q = ' '.join(translated)
|
||||
|
||||
@@ -380,20 +380,9 @@ class PlayerSession(LineReceiver):
|
||||
|
||||
def perform_status(self, data_parsed):
|
||||
self.sesskey = data_parsed['sesskey']
|
||||
|
||||
|
||||
self.status = data_parsed['__cmd_val__']
|
||||
self.statstring = data_parsed['statstring']
|
||||
self.locstring = data_parsed['locstring']
|
||||
|
||||
# fields = [
|
||||
# #("status", self.status),
|
||||
# ("stat", self.statstring),
|
||||
# ("loc", self.locstring),
|
||||
# ]
|
||||
#
|
||||
# for f in fields:
|
||||
# self.db.update_profile(self.sesskey, f)
|
||||
self.statstring = data_parsed['statstring']
|
||||
self.locstring = data_parsed['locstring']
|
||||
|
||||
# Send authorization requests to client
|
||||
self.get_buddy_requests()
|
||||
@@ -519,8 +508,10 @@ class PlayerSession(LineReceiver):
|
||||
|
||||
for buddy in self.buddies:
|
||||
if buddy['buddyProfileId'] in self.sessions:
|
||||
#self.log(logging.DEBUG, "Sending status to buddy id %s (%s:%d): %s" % (str(buddy['buddyProfileId']), self.sessions[buddy['buddyProfileId']].address.host, self.sessions[buddy['buddyProfileId']].address.port, msg))
|
||||
self.sessions[buddy['buddyProfileId']].transport.write(bytes(msg))
|
||||
|
||||
|
||||
def get_status_from_friends(self):
|
||||
# This will be called when the player logs in. Grab the player's buddy list and check the current sessions to
|
||||
# see if anyone is online. If they are online, make them send an update to the calling client.
|
||||
@@ -588,7 +579,10 @@ class PlayerSession(LineReceiver):
|
||||
|
||||
for message in messages:
|
||||
if message['sourceid'] not in self.blocked:
|
||||
self.transport.write(bytearray(message['msg']))
|
||||
try:
|
||||
self.transport.write(bytearray(message['msg']))
|
||||
except:
|
||||
self.transport.write(bytearray(message['msg'], "utf-8"))
|
||||
|
||||
if __name__ == "__main__":
|
||||
gsps = GameSpyProfileServer()
|
||||
|
||||
Reference in New Issue
Block a user