Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent Percent Character Transform

I am attempting to use the Web Deployment Toolkit with our MVC3 project and overall the deployment works fine but our connection string to the database has a password that contains a percent (%) character that is followed by two numbers. The deployment toolkit seems to be transforming this as a Hex character replacement. Is there a way to prevent this character replacement and still keep the connection string usable on developer machines? I tried putting in the replacement in the Web.Debug.Config file and even adding a %25 instead of just the % to try to have it replace just the % character and it still replaces the complete value.

Example:

<connectionStrings>
    <add name="MyDB" connectionString="server=Server1;uid=user1;pwd=abc123%72;database=Database1;"
</connectionStrings>

gets replaced with

<connectionStrings>
    <add name="MyDB" connectionString="server=Server1;uid=user1;pwd=abc123r;database=Database1;"
</connectionStrings>
like image 944
Adam Gritt Avatar asked Feb 03 '23 16:02

Adam Gritt


1 Answers

Set the pwd portion of the connection string to:

pwd=abc123%252572

After much trial and error, I discovered that It does a double pass. The first pass will convert %2525 to %25, the second pass converts %25 to %. That is why when you used %2572, it resulted in r (%72 is the Unicode code for r). This seems to me like a bug in the parser. Perhaps someone more knowledgeable can give a better explanation.

like image 117
mateuscb Avatar answered Feb 05 '23 16:02

mateuscb