Ensure app origin is encoded (bug 1065006)

I can use assert endswith here to make it a little less fragile