#24: Fix parsing of multiple paths where an earlier path contains an unclosed non-standard tag

This commit is contained in:
mtkennerly 2023-03-17 02:13:35 +08:00
parent af822f078c
commit 16c3911354
No known key found for this signature in database
GPG key ID: E764BE00BE6E6408
3 changed files with 98 additions and 88 deletions

View file

@ -37749,13 +37749,6 @@ Aspects of change:
store: microsoft
steam:
id: 1815780
Asphalt Xtreme:
files:
'{{p|programfiles}}/WindowsApps/A278AB0D.AsphaltXtreme_1.7.3.8_x86__h6adky7gbf63m':
tags:
- config
when:
- os: windows
Asphyxia:
installDir:
Asphyxia: {}
@ -45825,12 +45818,22 @@ Back to the Egg!:
- config
when:
- os: mac
<winDocuments>/Telltale Games/Episode */*.save|<winDocuments>/Telltale Games/Back to the Future 104/*.save:
<winDocuments>/Telltale Games/Back to the Future 104/*.save:
tags:
- save
when:
- os: windows
<winDocuments>/Telltale Games/Episode */prefs.prop|<winDocuments>/Telltale Games/Back to the Future 104/prefs.prop:
<winDocuments>/Telltale Games/Back to the Future 104/prefs.prop:
tags:
- config
when:
- os: windows
<winDocuments>/Telltale Games/Episode */*.save:
tags:
- save
when:
- os: windows
<winDocuments>/Telltale Games/Episode */prefs.prop:
tags:
- config
when:
@ -86478,11 +86481,6 @@ Cats are Liquid:
- save
when:
- os: windows
'{{p|HKEY_CURRENT_USER}}/SOFTWARE/LastQuarter Studios/Cats are Liquid':
tags:
- config
when:
- os: windows
installDir:
Cats are Liquid: {}
launch:
@ -183422,14 +183420,6 @@ Farming Simulator 15:
store: steam
steam:
id: 313160
Farming Simulator 16:
files:
'{{p|programfiles}}/WindowsApps/GIANTSSoftware.FarmingSimulator16_1.1.2.8_x86__fa8jxm5fj0esw':
tags:
- save
when:
- os: windows
store: microsoft
Farming Simulator 17:
files:
<winDocuments>/My Games/FarmingSimulator2017:
@ -298052,11 +298042,6 @@ Lucadian Chronicles:
- save
when:
- os: windows
'{{p|Linux}}~/.config/unity3d/melessthanthree/Lucah_ Born of a Dream':
tags:
- save
when:
- os: linux
installDir:
Lucah Born of a Dream: {}
launch:
@ -316473,13 +316458,6 @@ MetalArms:
MetalArms: {}
steam:
id: 1155860
'Metalheart: Replicants Rampage':
files:
'{{p|ProgramFiles}}/NumLock/Metalheart/data/save':
tags:
- save
when:
- os: windows
'Metaloid : Origin':
installDir:
Morigin: {}
@ -372775,13 +372753,6 @@ Phantasy Star Online 2 New Genesis:
store: steam
steam:
id: 1056640
Phantasy Star Universe:
files:
'{{p|}}<winLocalAppData>/SEGA/PHANTASY STAR UNIVERSE/Psu.ini':
tags:
- config
when:
- os: windows
Phantom:
installDir:
Phantom: {}
@ -410592,7 +410563,13 @@ Retro/Grade:
id: 222660
RetroArch:
files:
<base>/configs/*/*.opt|<base>/configs/*/*.cfg:
<base>/configs/*/*.cfg:
tags:
- config
when:
- os: windows
- os: mac
<base>/configs/*/*.opt:
tags:
- config
when:
@ -428806,12 +428783,22 @@ Sam & Max Hit the Road:
id: 355170
Sam & Max Save the World:
files:
<base>/*/*.save|<winDocuments>/Telltale Games/*/*.save:
<base>/*/*.save:
tags:
- save
when:
- os: windows
<base>/*/prefs.prop|<winDocuments>/Telltale Games/*/prefs.prop:
<base>/*/prefs.prop:
tags:
- config
when:
- os: windows
<winDocuments>/Telltale Games/*/*.save:
tags:
- save
when:
- os: windows
<winDocuments>/Telltale Games/*/prefs.prop:
tags:
- config
when:
@ -577384,12 +577371,22 @@ Wall to Wall:
id: 1027080
Wallace & Gromit's Grand Adventures:
files:
<winDocuments>/Telltale Games/Wallace and Gromit Ep*/*.save|<winDocuments>/Telltale Games/Wallace & Gromit - */*.save:
<winDocuments>/Telltale Games/Wallace & Gromit - */*.save:
tags:
- save
when:
- os: windows
<winDocuments>/Telltale Games/Wallace and Gromit Ep*/prefs.prop|<winDocuments>/Telltale Games/Wallace & Gromit - */prefs.prop:
<winDocuments>/Telltale Games/Wallace & Gromit - */prefs.prop:
tags:
- config
when:
- os: windows
<winDocuments>/Telltale Games/Wallace and Gromit Ep*/*.save:
tags:
- save
when:
- os: windows
<winDocuments>/Telltale Games/Wallace and Gromit Ep*/prefs.prop:
tags:
- config
when:

View file

@ -2244,6 +2244,7 @@
* [Asphalt 7: Heat](https://www.pcgamingwiki.com/wiki/?curid=24947)
* [Asphalt Overdrive](https://www.pcgamingwiki.com/wiki/?curid=171874)
* [Asphalt Street Storm Racing](https://www.pcgamingwiki.com/wiki/?curid=171872)
* [Asphalt Xtreme](https://www.pcgamingwiki.com/wiki/?curid=57248)
* [Asphyxia](https://www.pcgamingwiki.com/wiki/?curid=33642)
* [Aspire: Ina's Tale](https://www.pcgamingwiki.com/wiki/?curid=173772)
* [ASRECorp](https://www.pcgamingwiki.com/wiki/?curid=42155)
@ -11098,6 +11099,7 @@
* [Farming 6-in-1 bundle](https://www.pcgamingwiki.com/wiki/?curid=42746)
* [Farming Giant](https://www.pcgamingwiki.com/wiki/?curid=40524)
* [Farming Life](https://www.pcgamingwiki.com/wiki/?curid=128371)
* [Farming Simulator 16](https://www.pcgamingwiki.com/wiki/?curid=168192)
* [Farming Village](https://www.pcgamingwiki.com/wiki/?curid=144059)
* [Farming World](https://www.pcgamingwiki.com/wiki/?curid=50324)
* [Farmington County](https://www.pcgamingwiki.com/wiki/?curid=148886)
@ -19468,6 +19470,7 @@
* [Metal: Iron Age](https://www.pcgamingwiki.com/wiki/?curid=90252)
* [MetalArms](https://www.pcgamingwiki.com/wiki/?curid=149503)
* [MetälBörn](https://www.pcgamingwiki.com/wiki/?curid=180121)
* [Metalheart: Replicants Rampage](https://www.pcgamingwiki.com/wiki/?curid=35279)
* [Metaloid : Origin](https://www.pcgamingwiki.com/wiki/?curid=126010)
* [Metamorph (Chumoran)](https://www.pcgamingwiki.com/wiki/?curid=121083)
* [Metamorphabet](https://www.pcgamingwiki.com/wiki/?curid=48062)
@ -22904,6 +22907,7 @@
* [Phantasmat: The Dread of Oakville](https://www.pcgamingwiki.com/wiki/?curid=112812)
* [Phantasmat: The Endless Night](https://www.pcgamingwiki.com/wiki/?curid=62239)
* [Phantasmata](https://www.pcgamingwiki.com/wiki/?curid=132901)
* [Phantasy Star Universe](https://www.pcgamingwiki.com/wiki/?curid=17795)
* [Phantasy Star Universe: Ambition of the Illuminus](https://www.pcgamingwiki.com/wiki/?curid=169291)
* [Phantom](https://www.pcgamingwiki.com/wiki/?curid=59661)
* [Phantom Astronaut Lucid VR](https://www.pcgamingwiki.com/wiki/?curid=149344)

View file

@ -293,6 +293,14 @@ function makePathArgRegex(arg: string): RegExp {
return new RegExp(escaped, "gi");
}
function normalizePath(path: string): string {
return path
.replace(/\\/g, "/")
.replace(/\/{2,}/g, "/")
.replace(/\/(?=$)/g, "")
.replace(/^~(?=($|\/))/, "<home>");
}
/**
* https://www.pcgamingwiki.com/wiki/Template:Path
*/
@ -315,11 +323,7 @@ function parsePath(path: string): [string, PathType] {
}
}
path = path
.replace(/\\/g, "/")
.replace(/\/{2,}/g, "/")
.replace(/\/(?=$)/g, "")
.replace(/^~(?=($|\/))/, "<home>")
path = normalizePath(path)
.replace(/%userprofile%\/AppData\/Roaming/i, "<winAppData>")
.replace(/%userprofile%\/AppData\/Local(?!Low)/i, "<winLocalAppData>")
.replace(/%userprofile%\/Documents/i, "<winDocuments>")
@ -691,51 +695,56 @@ export function parseTemplates(templates: Array<string>): Pick<Game, "files" | "
continue;
}
const [path, pathType] = parsePath(rawPath);
if (pathIsTooBroad(path)) {
const [pathUnsplit, pathType] = parsePath(rawPath);
if (pathUnsplit.includes("{{")) {
continue;
}
if (pathType === PathType.FileSystem) {
const constraint = getConstraintFromSystem(system, rawPath);
if (!game.files.hasOwnProperty(path)) {
game.files[path] = {
when: [],
tags: [],
};
for (const path of pathUnsplit.split("|").map(normalizePath)) {
if (pathIsTooBroad(path)) {
continue;
}
if (!game.files[path].when.some(x => x.os === constraint.os && x.store === constraint.store)) {
if (constraint.os !== undefined && constraint.store !== undefined) {
game.files[path].when.push(constraint);
} else if (constraint.os !== undefined) {
game.files[path].when.push({ os: constraint.os });
} else if (constraint.store !== undefined) {
game.files[path].when.push({ store: constraint.store });
if (pathType === PathType.FileSystem) {
const constraint = getConstraintFromSystem(system, rawPath);
if (!game.files.hasOwnProperty(path)) {
game.files[path] = {
when: [],
tags: [],
};
}
}
const tag = getTagFromTemplate(template.name);
if (tag !== undefined && !game.files[path].tags.includes(tag)) {
game.files[path].tags.push(tag);
}
} else if (pathType === PathType.Registry) {
if (!game.registry.hasOwnProperty(path)) {
game.registry[path] = {
when: [],
tags: [],
};
}
if (!game.files[path].when.some(x => x.os === constraint.os && x.store === constraint.store)) {
if (constraint.os !== undefined && constraint.store !== undefined) {
game.files[path].when.push(constraint);
} else if (constraint.os !== undefined) {
game.files[path].when.push({ os: constraint.os });
} else if (constraint.store !== undefined) {
game.files[path].when.push({ store: constraint.store });
}
}
const store = getStoreConstraintFromPath(rawPath);
if (store !== undefined && !game.registry[path].when.some(x => x.store === store)) {
game.registry[path].when.push({ store });
}
const tag = getTagFromTemplate(template.name);
if (tag !== undefined && !game.files[path].tags.includes(tag)) {
game.files[path].tags.push(tag);
}
} else if (pathType === PathType.Registry) {
if (!game.registry.hasOwnProperty(path)) {
game.registry[path] = {
when: [],
tags: [],
};
}
const tag = getTagFromTemplate(template.name);
if (tag !== undefined && !game.registry[path].tags.includes(tag)) {
game.registry[path].tags.push(tag);
const store = getStoreConstraintFromPath(rawPath);
if (store !== undefined && !game.registry[path].when.some(x => x.store === store)) {
game.registry[path].when.push({ store });
}
const tag = getTagFromTemplate(template.name);
if (tag !== undefined && !game.registry[path].tags.includes(tag)) {
game.registry[path].tags.push(tag);
}
}
}
}