Converted over to new name sanitization routine
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include "WingTypes.h"
|
||||
#include "WingServer.h"
|
||||
#include "WingHandler.h"
|
||||
#include "WingTokenizer.h"
|
||||
#include "Engine/Blueprint.h"
|
||||
#include "Engine/MemberReference.h"
|
||||
#include "Engine/World.h"
|
||||
@@ -56,50 +57,31 @@
|
||||
|
||||
FString WingUtils::SanitizeName(const FString &InName)
|
||||
{
|
||||
FString Name = InName;
|
||||
int32 Dst = 0;
|
||||
for (int32 Src = 0; Src < Name.Len(); Src++)
|
||||
{
|
||||
TCHAR c = Name[Src];
|
||||
if (c < 0x20 || c == 0x7F) continue;
|
||||
if (c == ' ') c=L'·';
|
||||
if (c == '<') c=L'◁';
|
||||
if (c == '>') c=L'▷';
|
||||
if (c == '(') c=L'❨';
|
||||
if (c == ')') c=L'❩';
|
||||
if (c == '=') c=L'≡';
|
||||
if (c == ',') c=L'▾';
|
||||
Name[Dst++] = c;
|
||||
}
|
||||
if (Dst == 0) Name[Dst++] = L'·';
|
||||
Name.LeftInline(Dst);
|
||||
return Name;
|
||||
return WingTokenizer::ExternalizeID(InName);
|
||||
}
|
||||
|
||||
FString WingUtils::UnsanitizeName(const FString &InName)
|
||||
{
|
||||
FString Name = InName;
|
||||
int32 Dst = 0;
|
||||
for (int32 Src = 0; Src < Name.Len(); Src++)
|
||||
{
|
||||
TCHAR c = Name[Src];
|
||||
if (c < 0x20 || c == 0x7F) continue;
|
||||
if (c == L'·') c=' ';
|
||||
if (c == L'◁') c='<';
|
||||
if (c == L'▷') c='>';
|
||||
if (c == L'❨') c='(';
|
||||
if (c == L'❩') c=')';
|
||||
if (c == L'≡') c='=';
|
||||
if (c == L'▾') c=',';
|
||||
Name[Dst++] = c;
|
||||
}
|
||||
Name.LeftInline(Dst);
|
||||
return Name;
|
||||
FString Error;
|
||||
return WingTokenizer::TryInternalizeID(InName, Error);
|
||||
}
|
||||
|
||||
FString WingUtils::SanitizeName(FName Name)
|
||||
{
|
||||
return SanitizeName(Name.ToString());
|
||||
return WingTokenizer::ExternalizeID(Name.ToString());
|
||||
}
|
||||
|
||||
FString WingUtils::CheckProposedName(const FString &ExternalID)
|
||||
{
|
||||
FString InternalID = WingTokenizer::CheckInternalizeID(ExternalID);
|
||||
if (!InternalID.IsEmpty() && WingTokenizer::WouldExternalizeReadably(InternalID))
|
||||
{
|
||||
UWingServer::Printf(TEXT("ERROR: id %s would not be a readable id, may not create item with this name"),
|
||||
*ExternalID);
|
||||
UWingServer::SuggestManual(WingManual::Section::IdentifierSanitization);
|
||||
return FString();
|
||||
}
|
||||
return InternalID;
|
||||
}
|
||||
|
||||
FString WingUtils::StandardizeMenuItem(const FString &Item)
|
||||
@@ -128,16 +110,7 @@ FString WingUtils::StandardizeMenuItem(const FString &Item)
|
||||
return Sanitized;
|
||||
}
|
||||
|
||||
FString WingUtils::CheckProposedName(const FString &Name)
|
||||
{
|
||||
FString Unsanitized = UnsanitizeName(Name);
|
||||
if ((Unsanitized.IsEmpty()) || (SanitizeName(Unsanitized) != Name))
|
||||
{
|
||||
UWingServer::Printf(TEXT("Names must not contain control characters or be empty\n"));
|
||||
return FString();
|
||||
}
|
||||
return Unsanitized;
|
||||
}
|
||||
|
||||
|
||||
// ============================================================
|
||||
// Name Lookup
|
||||
|
||||
Reference in New Issue
Block a user