handle crc collisions

This commit is contained in:
ed 2021-11-10 23:59:07 +01:00
parent e9b14464ee
commit 5533b47099

View file

@ -1620,7 +1620,7 @@ function eval_hash() {
if (v.indexOf('#af-') === 0) { if (v.indexOf('#af-') === 0) {
var id = v.slice(2).split('&'); var id = v.slice(2).split('&');
if (id[0].length != 10) if (id[0].length < 10)
return; return;
if (id.length == 1) if (id.length == 1)
@ -3838,7 +3838,8 @@ var treectl = (function () {
var top = this.top, var top = this.top,
nodes = res.dirs.concat(res.files), nodes = res.dirs.concat(res.files),
html = mk_files_header(res.taglist); html = mk_files_header(res.taglist),
seen = {};
showfile.files = []; showfile.files = [];
html.push('<tbody>'); html.push('<tbody>');
@ -3852,6 +3853,10 @@ var treectl = (function () {
id = 'f-' + ('00000000' + crc32(fname)).slice(-8), id = 'f-' + ('00000000' + crc32(fname)).slice(-8),
lang = showfile.getlang(fname); lang = showfile.getlang(fname);
while (seen[id])
id += 'a';
seen[id] = 1;
if (lang) if (lang)
showfile.files.push({ 'id': id, 'name': fname }); showfile.files.push({ 'id': id, 'name': fname });
@ -4376,11 +4381,18 @@ function addcrc() {
'#files>tbody>tr>td:first-child+td>' + ( '#files>tbody>tr>td:first-child+td>' + (
ebi('unsearch') ? 'div>a:last-child' : 'a')); ebi('unsearch') ? 'div>a:last-child' : 'a'));
for (var a = 0, aa = links.length; a < aa; a++) var seen = {}; // ejyefs ev69gg y9j8sg .opus
if (!links[a].getAttribute('id')) { for (var a = 0, aa = links.length; a < aa; a++) {
var id = links[a].getAttribute('id');
if (!id) {
var crc = crc32(links[a].textContent || links[a].innerText); var crc = crc32(links[a].textContent || links[a].innerText);
crc = ('00000000' + crc).slice(-8); id = 'f-' + ('00000000' + crc).slice(-8);
links[a].setAttribute('id', 'f-' + crc); while (seen[id])
id += 'a';
links[a].setAttribute('id', id);
}
seen[id] = 1;
} }
} }