server.db is a hash table written to file so white space is very important. The "stuff like %2F and %2B" is url encoding (here's
a website that can do it).
For demonstration purposes, I will outline the steps one could take to merge ids with bash, using a little help from
php (for convenience). This is untested and only theoretical until someone tells me it won't deserialize properly. Make backups first.
In a GNU+Linux environment we could define two helper functions to make it easy to translate encoded keys:
Code:
#!/bin/bash
function _url_decode() { php -r "echo urldecode(file_get_contents('php://stdin'));"; };
function _url_encode() { php -r "echo urlencode(file_get_contents('php://stdin'));"; };
We can verify that these functions work by greping for records in server.db that contain keys. awk is used to split by delimiter "\", and grab the key chunk, then we pipe it to our _url_decode helper function.
Code:
grep "cts100record/speed/crypto_idfp" /home/z/.xonotic/data/data/server.db |awk -F "\\" '{ print $3 }' |sort |uniq |_url_decode
xQMEUcegy8s47JRH01kgPn/xA5q2XWvWqtOXyeJ4SEo=
...
This gets us the decoded keys.
Knowing this, lets revisit our challenge, we want to "merge ids", or as you noted, it's actually a find/replace. Under the assumption that you'll be finding and replacing many keys, lets go ahead, and create a
replace.txt file, where the first column is the old key and the second column is the new key (obviously fake for effect).
Code:
xQMEUcegy8jG7JRH0OkgPn/xA5q2XWvWqtOXyeJ4SEo= MYnewKEY=
xQMEUcegy853453JRH0OkgPn/xA5asdfas2XyeJ4SEo= MYnewKEY=
...
We can read through this list of keys to find/replace and apply it to our server.db as such:
Code:
while read old new; do o=$(echo -n $old|_url_encode); n=$(echo -n $new|_url_encode); echo $o; sed -i "s/$o/$n/g" /home/z/.xonotic/data/data/server.db; done < replace.txt
and if we check out server.db now, those keys should be replaced.
Code:
\sxb1/cts100record/speed/crypto_idfp\MYnewKEY%3D
\sxb1/cts100record/speed/crypto_idfp\MYnewKEY%3D
Hope this helps!