How to find out if string has already been URL encoded?

后端 未结 11 1038
死守一世寂寞
死守一世寂寞 2020-11-30 03:46

How could I check if string has already been encoded?

For example, if I encode TEST==, I get TEST%3D%3D. If I again encode last string, I

11条回答
  •  时光说笑
    2020-11-30 04:14

    Decode, compare to original. If it does differ, original is encoded. If it doesn't differ, original isn't encoded. But still it says nothing about whether the newly decoded version isn't still encoded. A good task for recursion.

    I hope one can't write a quine in urlencode, or this algorithm would get stuck.

    Exception: When a string contains "+" character url decoder replaces it with a space even though the string is not url encoded

提交回复
热议问题