c# - Encrypted Querystring in URL getting changed to lowercase in Outlook -


i providing cancel button in registration email, user can click link , cancel registration.

this works fine except outlook converting links lowercase. when user clicks link, can't decrypt url because encrypted querystring lowercase , longer valid.

what can prevent outlook converting links lowercase, or how can provide link url encrypted , case insensitive?

summary:

domain.com/cancel?qs=ylway3mdmmwmw

is getting changed to:

domain.com/cancel?qs=ylway3mdmmwmw

which breaks ability decrypt querystring.

if outlook sabotaging links, need make links case indifferent. if absolutely must keep upper , lowercase in links decryption, use marker character:

  1. generate encrypted string.
  2. before each upper case character, insert marker character (pick valid character encryption scheme not use).
  3. insert new string link.
  4. to decrypt, remove marker characters parse string , make uppercase/lowercase appropriate.

here pair of helper methods if find easier reading code:

            private static string encodecasingindifference(string originaltext, char markerchar)     {         stringbuilder sb = new stringbuilder();          foreach(char c in originaltext)         {             if (char.isupper(c))                 sb.append(markerchar);              sb.append(c);         }          return sb.tostring();     }      private static string decodecasingindifference(string encryptedtext, char markerchar)     {         stringbuilder sb = new stringbuilder();         bool nextcharisupper = false;          foreach(char c in encryptedtext)         {             if(c == markerchar)             {                 nextcharisupper = true;                 continue;             }              if(nextcharisupper)                 sb.append(char.toupperinvariant(c));             else                 sb.append(char.tolowerinvariant(c));              nextcharisupper = c == markerchar;         }          return sb.tostring();     } 

passing original link payload "enode" method dash ('-') marker character returns: -y-lway3m-d-mm-w-mw

passing -y-lway3m-d-mn-w-mw "decode" method dash ('-') marker character returns original link payload


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -