Fixed possible issue in Users.FindUser and Users.UserLink.

This commit is contained in:
Dario Solera 2010-03-25 06:00:52 +00:00
parent 0cb35ce558
commit 33357b97cf
2 changed files with 6 additions and 3 deletions

View file

@ -16,5 +16,5 @@ using System.Reflection;
// //
// You can specify all the values or you can default the Revision and Build Numbers // You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
[assembly: AssemblyVersion("3.0.2.511")] [assembly: AssemblyVersion("3.0.2.512")]
[assembly: AssemblyFileVersion("3.0.2.511")] [assembly: AssemblyFileVersion("3.0.2.512")]

View file

@ -88,6 +88,8 @@ namespace ScrewTurn.Wiki {
/// <param name="username">The username.</param> /// <param name="username">The username.</param>
/// <returns>The user, or <c>null</c>.</returns> /// <returns>The user, or <c>null</c>.</returns>
public static UserInfo FindUser(string username) { public static UserInfo FindUser(string username) {
if(string.IsNullOrEmpty(username)) return null;
if(username == "admin") return GetAdministratorAccount(); if(username == "admin") return GetAdministratorAccount();
// Try default provider first // Try default provider first
@ -545,10 +547,11 @@ namespace ScrewTurn.Wiki {
/// <param name="newWindow">A value indicating whether to open the link in a new window.</param> /// <param name="newWindow">A value indicating whether to open the link in a new window.</param>
/// <returns>The User link.</returns> /// <returns>The User link.</returns>
public static string UserLink(string username, bool newWindow) { public static string UserLink(string username, bool newWindow) {
if(string.IsNullOrEmpty(username)) return "???";
if(username != null && (username.EndsWith("+" + Log.SystemUsername) || username == Log.SystemUsername)) return username; if(username != null && (username.EndsWith("+" + Log.SystemUsername) || username == Log.SystemUsername)) return username;
UserInfo u = FindUser(username); UserInfo u = FindUser(username);
if(u == null && username.Equals("admin")) u = new UserInfo("admin", null, Settings.ContactEmail, true, DateTime.Now, null);
if(u != null) { if(u != null) {
return @"<a " + return @"<a " +
(newWindow ? "target=\"_blank\" " : "") + (newWindow ? "target=\"_blank\" " : "") +