Skip to content

Commit b496798

Browse files
committed
Traversal fix
1 parent dcebeec commit b496798

File tree

3 files changed

+10
-16
lines changed

3 files changed

+10
-16
lines changed

src/lib/client/superForm.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,9 @@ export function superForm<
12871287
if (taintOptions == 'ignore') return;
12881288

12891289
const paths = comparePaths(newData, Data.form);
1290+
//console.log('paths:', JSON.stringify(paths));
12901291
const newTainted = comparePaths(newData, Tainted.clean).map((path) => path.join());
1292+
//console.log('newTainted:', JSON.stringify(newTainted));
12911293

12921294
if (paths.length) {
12931295
if (taintOptions == 'untaint-all' || taintOptions == 'untaint-form') {
@@ -1302,13 +1304,17 @@ export function superForm<
13021304

13031305
const currentValue = traversePath(newData, path);
13041306
const cleanPath = traversePath(Tainted.clean, path);
1305-
return currentValue && cleanPath && currentValue.value === cleanPath.value
1307+
const identical = currentValue && cleanPath && currentValue.value === cleanPath.value;
1308+
1309+
const output = identical
13061310
? undefined
13071311
: taintOptions === true
13081312
? true
13091313
: taintOptions === 'untaint'
13101314
? undefined
13111315
: data.value;
1316+
1317+
return output;
13121318
});
13131319

13141320
return currentlyTainted;

src/lib/traversal.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -164,20 +164,7 @@ export function comparePaths(newObj: unknown, oldObj: unknown) {
164164
traversePaths(newObj as object, (data) => checkPath(data, oldObj as object));
165165
traversePaths(oldObj as object, (data) => checkPath(data, newObj as object));
166166

167-
// Need to add the object (non-leaf) path to diffPaths, otherwise the traversal could fail
168-
// when being used elsewhere (Tainted_update)
169-
for (const path of diffPaths.keys()) {
170-
const arr = path.split(' ').slice(0, -1);
171-
while (arr.length) {
172-
const key = arr.join(' ');
173-
if (!diffPaths.has(key)) {
174-
diffPaths.set(key, [...arr]);
175-
}
176-
arr.pop();
177-
}
178-
}
179-
180-
// Need to sort it as well, so the shortest paths comes first
167+
// Need to sort the list so the shortest paths comes first
181168
const output = Array.from(diffPaths.values());
182169
output.sort((a, b) => a.length - b.length);
183170
return output;

src/routes/(v2)/v2/Navigation.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@
7777
'bigint',
7878
'issue-455',
7979
'vine',
80-
'timeproxy'
80+
'timeproxy',
81+
'tainted-null-random'
8182
].sort();
8283
</script>
8384

0 commit comments

Comments
 (0)