Use valid xml to configure policies.
In your examples one can find lines like this one:
<set-variable name="isMobile" value="@(context.Request.Headers["User-Agent"].Contains("iPad") || context.Request.Headers["User-Agent"].Contains("iPhone"))" />
If you try to validate this xml, you will find out that those double quotes inside of the value attribute are not allowed.
Martin Palmer commented
This is still broken, it would be good to either have `valid` xml or a schema to apply against the policy to ensure content is good.