Fix path accepted characters

This commit is contained in:
barsdeveloper
2023-04-16 21:47:49 +02:00
parent 6ef2225396
commit e06589bc46
5 changed files with 33 additions and 98 deletions

View File

@@ -5,81 +5,6 @@ import Configuration from "../../js/Configuration.js"
import SVGIcon from "../../js/SVGIcon.js"
const tests = [
/*{
name: "ROS Change Element",
value: String.raw`
Begin Object Class=K2Node_CallFunction Name="K2Node_CallFunction_131095"
NodePosX=-5024
NodePosY=-1888
NodeGuid=CC44F0434996CC21484572A242E1F72D
Begin Object Class=EdGraphPin Name="EdGraphPin_3991113"
End Object
Begin Object Class=EdGraphPin Name="EdGraphPin_3991114"
End Object
Begin Object Class=EdGraphPin Name="EdGraphPin_3991115"
End Object
Begin Object Class=EdGraphPin Name="EdGraphPin_3991116"
End Object
Begin Object Class=EdGraphPin Name="EdGraphPin_3991117"
End Object
Begin Object Class=EdGraphPin Name="EdGraphPin_3991118"
End Object
FunctionReference=(MemberParentClass=Class'/Script/ShooterGame.ShooterGameMode',MemberName="GetFloatOptionIni")
Pins(0)=EdGraphPin'EdGraphPin_3991113'
Pins(1)=EdGraphPin'EdGraphPin_3991114'
Pins(2)=EdGraphPin'EdGraphPin_3991115'
Pins(3)=EdGraphPin'EdGraphPin_3991116'
Pins(4)=EdGraphPin'EdGraphPin_3991117'
Pins(5)=EdGraphPin'EdGraphPin_3991118'
ErrorType=1
ErrorMsg="Error This blueprint (self) is not a ShooterGameMode, therefore \' Target \' must have a connection\nError This blueprint (self) is not a ShooterGameMode, therefore \' Target \' must have a connection"
Begin Object Name="EdGraphPin_3991113"
PinName="execute"
PinType=(PinCategory="exec")
LinkedTo(0)=EdGraphPin'"K2Node_CallFunction_113214.EdGraphPin_3991579"'
End Object
Begin Object Name="EdGraphPin_3991114"
PinName="then"
Direction=EGPD_Output
PinType=(PinCategory="exec")
LinkedTo(0)=EdGraphPin'"K2Node_IfThenElse_7680.EdGraphPin_3991155"'
End Object
Begin Object Name="EdGraphPin_3991115"
PinName="self"
PinFriendlyName="Target"
PinToolTip="Target\nShooter Game Mode Reference"
PinType=(PinCategory="object",PinSubCategoryObject=Class'/Script/ShooterGame.ShooterGameMode')
LinkedTo(0)=EdGraphPin'"K2Node_DynamicCast_2126.EdGraphPin_3990988"'
End Object
Begin Object Name="EdGraphPin_3991116"
PinName="Section"
PinToolTip="Section\nString"
PinType=(PinCategory="string")
DefaultValue="CrazysDinosStats"
End Object
Begin Object Name="EdGraphPin_3991117"
PinName="OptionName"
PinToolTip="Option Name\nString"
PinType=(PinCategory="string")
DefaultValue="DinoStamina"
End Object
Begin Object Name="EdGraphPin_3991118"
PinName="ReturnValue"
PinToolTip="Return Value\nFloat"
Direction=EGPD_Output
PinType=(PinCategory="float")
DefaultValue="0.0"
AutogeneratedDefaultValue="0.0"
LinkedTo(0)=EdGraphPin'"K2Node_CallFunction_131096.EdGraphPin_3991132"'
LinkedTo(1)=EdGraphPin'"K2Node_CallFunction_131097.EdGraphPin_3991144"'
LinkedTo(2)=EdGraphPin'"K2Node_VariableSet_21447.EdGraphPin_3992243"'
End Object
End Object
`,
pins: 2,
delegate: false,
development: false,
},*/
{
name: "Flip Flop",
value: String.raw`

View File

@@ -117,17 +117,17 @@ describe("Serializer", () => {
context("ObjectReferenceEntity", () => {
let serializer = SerializerFactory.getSerializer(ObjectReferenceEntity)
it("Parses Class", () =>
it(`Parses Class`, () =>
expect(serializer.read("Class"))
.to.be.instanceOf(ObjectReferenceEntity)
.and.to.deep.contain({ type: "Class", path: "" })
)
it("Parses Class'/Script/ShooterGame.ShooterGameMode'", () =>
it(`Parses Class'/Script/ShooterGame.ShooterGameMode'`, () =>
expect(serializer.read(`Class'/Script/ShooterGame.ShooterGameMode'`))
.to.be.instanceOf(ObjectReferenceEntity)
.and.to.deep.contain({ type: "Class", path: "/Script/ShooterGame.ShooterGameMode" })
)
it("Parses EdGraphPin'EdGraphPin_45417'", () =>
it(`Parses EdGraphPin'EdGraphPin_45417'`, () =>
expect(serializer.read(`EdGraphPin'EdGraphPin_45417'`))
.to.be.instanceOf(ObjectReferenceEntity)
.and.to.deep.contain({ type: "EdGraphPin", path: "EdGraphPin_45417" })
@@ -147,6 +147,16 @@ describe("Serializer", () => {
.to.be.instanceOf(ObjectReferenceEntity)
.and.to.deep.contain({ type: "Function", path: "/Game/Mods/CrazyDinos/ElementalDragon/CDElementalDragon_Character_BP.SKEL_CDElementalDragon_Character_BP_C:ROS Change Element" })
)
it(`Parses EdGraph'/Game/Systems/BP_MacroGlobal.BP_MacroGlobal:Or+Branch'`, () =>
expect(serializer.read(`EdGraph'/Game/Systems/BP_MacroGlobal.BP_MacroGlobal:Or+Branch'`))
.to.be.instanceOf(ObjectReferenceEntity)
.and.to.deep.contain({ type: "EdGraph", path: "/Game/Systems/BP_MacroGlobal.BP_MacroGlobal:Or+Branch" })
)
it(`Parses /Script/Engine.EdGraph'"+-Weird/2,Macro"'`, () =>
expect(serializer.read(`/Script/Engine.EdGraph'"+-Weird/2,Macro"'`))
.to.be.instanceOf(ObjectReferenceEntity)
.and.to.deep.contain({ type: "/Script/Engine.EdGraph", path: "+-Weird/2,Macro" })
)
})
context("GuidEntity", () => {

22
dist/ueblueprint.js vendored
View File

@@ -2953,7 +2953,7 @@ class ObjectEntity extends IEntity {
},
{}
);
// Reorder suboejcts to be the first
// Reorder sub objects to be the first entries
values = {
...subObjectsValues,
...values,
@@ -3003,7 +3003,7 @@ class ObjectEntity extends IEntity {
/** @type {String?} */ this.ErrorMsg;
/** @type {(PinEntity | UnknownPinEntity)[]} */ this.CustomProperties;
// Legacy objects transform into pins
// Legacy nodes cleanup
if (this["Pins"] instanceof Array) {
this["Pins"]
.forEach(
@@ -3016,9 +3016,9 @@ class ObjectEntity extends IEntity {
this.CustomProperties.push(pinEntity);
}
});
delete this["Pins"];
}
// Legacy path names
this.Class.sanitize();
if (this.MacroGraphReference) {
this.MacroGraphReference.MacroGraph?.sanitize();
@@ -3458,6 +3458,7 @@ class Grammar {
static InlineOptWhitespace = /[^\S\n]*/
static InlineWhitespace = /[^\S\n]+/
static InsideString = /(?:[^"\\]|\\.)*/
static InsideSingleQuotedString = /(?:[^'\\]|\\.)*/
static Integer = /[\-\+]?\d+(?!\d|\.)/
static MultilineWhitespace = /\s*\n\s*/
static Number = /[-\+]?\d+(?:\.\d+)?(?!\d|\.)/
@@ -3468,7 +3469,6 @@ class Grammar {
static PathFragment = Grammar.separatedBy(this.Symbol.source, "[\\.:]")
static PathSpaceFragment = Grammar.separatedBy(this.Symbol.source, "[\\.:\\ ]")
static Path = new RegExp(`(?:\\/${this.PathFragment.source}){2,}`) // Multiple (2+) /PathFragment
static PathOptSpace = new RegExp(`(?:\\/${this.PathSpaceFragment.source}){2,}`)
}
/* --- Primitive --- */
@@ -3497,18 +3497,18 @@ class Grammar {
static word = P.regex(Grammar.Regex.Word)
static pathQuotes = Grammar.regexMap(
new RegExp(
`'(` + Grammar.Regex.PathOptSpace.source + `|` + Grammar.Regex.PathFragment.source + `)'`
+ `|"(` + Grammar.Regex.PathOptSpace.source + `|` + Grammar.Regex.PathFragment.source + `)"`
+ `|'"(` + Grammar.Regex.PathOptSpace.source + `|` + Grammar.Regex.PathFragment.source + `)"'`
`'"(` + Grammar.Regex.InsideString.source + `)"'`
+ `|'(` + Grammar.Regex.InsideSingleQuotedString.source + `)'`
+ `|"(` + Grammar.Regex.InsideString.source + `)"`
),
([_0, a, b, c]) => a ?? b ?? c
)
static path = Grammar.regexMap(
new RegExp(
`(` + Grammar.Regex.Path.source + `)`
+ `|'(` + Grammar.Regex.PathOptSpace.source + `)'`
+ `|"(` + Grammar.Regex.PathOptSpace.source + `)"`
+ `|'"(` + Grammar.Regex.PathOptSpace.source + `)"'`
`'"(` + Grammar.Regex.InsideString.source + `)"'`
+ `|'(` + Grammar.Regex.InsideSingleQuotedString.source + `)'`
+ `|"(` + Grammar.Regex.InsideString.source + `)"`
+ `|(` + Grammar.Regex.Path.source + `)`
),
([_0, a, b, c, d]) => a ?? b ?? c ?? d
)

File diff suppressed because one or more lines are too long

View File

@@ -62,6 +62,7 @@ export default class Grammar {
static InlineOptWhitespace = /[^\S\n]*/
static InlineWhitespace = /[^\S\n]+/
static InsideString = /(?:[^"\\]|\\.)*/
static InsideSingleQuotedString = /(?:[^'\\]|\\.)*/
static Integer = /[\-\+]?\d+(?!\d|\.)/
static MultilineWhitespace = /\s*\n\s*/
static Number = /[-\+]?\d+(?:\.\d+)?(?!\d|\.)/
@@ -72,7 +73,6 @@ export default class Grammar {
static PathFragment = Grammar.separatedBy(this.Symbol.source, "[\\.:]")
static PathSpaceFragment = Grammar.separatedBy(this.Symbol.source, "[\\.:\\ ]")
static Path = new RegExp(`(?:\\/${this.PathFragment.source}){2,}`) // Multiple (2+) /PathFragment
static PathOptSpace = new RegExp(`(?:\\/${this.PathSpaceFragment.source}){2,}`)
}
/* --- Primitive --- */
@@ -101,18 +101,18 @@ export default class Grammar {
static word = P.regex(Grammar.Regex.Word)
static pathQuotes = Grammar.regexMap(
new RegExp(
`'(` + Grammar.Regex.PathOptSpace.source + `|` + Grammar.Regex.PathFragment.source + `)'`
+ `|"(` + Grammar.Regex.PathOptSpace.source + `|` + Grammar.Regex.PathFragment.source + `)"`
+ `|'"(` + Grammar.Regex.PathOptSpace.source + `|` + Grammar.Regex.PathFragment.source + `)"'`
`'"(` + Grammar.Regex.InsideString.source + `)"'`
+ `|'(` + Grammar.Regex.InsideSingleQuotedString.source + `)'`
+ `|"(` + Grammar.Regex.InsideString.source + `)"`
),
([_0, a, b, c]) => a ?? b ?? c
)
static path = Grammar.regexMap(
new RegExp(
`(` + Grammar.Regex.Path.source + `)`
+ `|'(` + Grammar.Regex.PathOptSpace.source + `)'`
+ `|"(` + Grammar.Regex.PathOptSpace.source + `)"`
+ `|'"(` + Grammar.Regex.PathOptSpace.source + `)"'`
`'"(` + Grammar.Regex.InsideString.source + `)"'`
+ `|'(` + Grammar.Regex.InsideSingleQuotedString.source + `)'`
+ `|"(` + Grammar.Regex.InsideString.source + `)"`
+ `|(` + Grammar.Regex.Path.source + `)`
),
([_0, a, b, c, d]) => a ?? b ?? c ?? d
)