Re: Dynamic DNS Stopped Working
Posted: Mon Mar 29, 2010 12:34 pm
You're absolutely right -- your unescape strategy is better, because it should be able to handle all escaped characters, not just the special ones that need to be escaped.
However, there is a bug in your code. There is an edge case where it fails. Consider the following escaped string: "abc%2540def%2540ghi"
%25 is the escape sequence for the "%" character and %40 is the escape sequence for the "@" character.
This should be unescaped to: "abc%40def%40ghi" Your code will transform this to "abc@def@ghi".
I've updated your proposed function to fix this error by making sure "%" gets unescaped last, and replaced my old implementation.
Thanks for your contribution! In case you want to become a regular contributor this counts as your first patch. My policy is to grant anyone who contributes 3 patches that are accepted commit access to the SVN.
However, there is a bug in your code. There is an edge case where it fails. Consider the following escaped string: "abc%2540def%2540ghi"
%25 is the escape sequence for the "%" character and %40 is the escape sequence for the "@" character.
This should be unescaped to: "abc%40def%40ghi" Your code will transform this to "abc@def@ghi".
I've updated your proposed function to fix this error by making sure "%" gets unescaped last, and replaced my old implementation.
Thanks for your contribution! In case you want to become a regular contributor this counts as your first patch. My policy is to grant anyone who contributes 3 patches that are accepted commit access to the SVN.