Procházet zdrojové kódy

* Membership.cs (GeneratePassword): don't include quotes (',",`)
in the set of characters in the generated passwords.

2006-05-01 Chris Toshok <[email protected]>


svn path=/trunk/mcs/; revision=60133

Chris Toshok před 19 roky
rodič
revize
655febdcfa

+ 5 - 0
mcs/class/System.Web/System.Web.Security/ChangeLog

@@ -1,3 +1,8 @@
+2006-05-01  Chris Toshok  <[email protected]>
+
+	* Membership.cs (GeneratePassword): don't include quotes (',",`)
+	in the set of characters in the generated passwords.
+
 2006-05-01  Chris Toshok  <[email protected]>
 
 	* MembershipProvider.cs (GetAlg): switch from Exception to

+ 14 - 0
mcs/class/System.Web/System.Web.Security/Membership.cs

@@ -115,6 +115,14 @@ namespace System.Web.Security
 				    || (pass_bytes[i] >= 91 && pass_bytes[i] <= 96)
 				    || (pass_bytes[i] >= 123 && pass_bytes[i] <= 126))
 					num_nonalpha++;
+
+				/* get rid of any quotes in the
+				 * password, just in case they cause
+				 * problems */
+				if (pass_bytes[i] == 34 || pass_bytes[i] == 39)
+					pass_bytes[i] ++;
+				else if (pass_bytes[i] == 96)
+					pass_bytes[i] --;
 			}
 
 			if (num_nonalpha < numberOfNonAlphanumericCharacters) {
@@ -136,6 +144,12 @@ namespace System.Web.Security
 						pass_bytes[i] = (byte)((pass_bytes[i] - 97) % 13 + 33);
 						num_nonalpha++;
 					}
+
+					/* and make sure we don't end up with quote characters */
+					if (pass_bytes[i] == 34 || pass_bytes[i] == 39)
+						pass_bytes[i]++;
+					else if (pass_bytes[i] == 96)
+						pass_bytes[i] --;
 				}
 			}