So I finally managed to get to the bottom of the issue. For some reason when extracting 7zip files escapeshellarg() didn't escape apostrophes in the expected manner, and I had to do a little workaround.
This should fix this problem for all possible instances.