{"record":{"id":"1d4cc82cf4f29905","repo":"can1357/oh-my-pi","slug":"invalid-rar5-utf-8-member-name","errorCode":null,"errorMessage":"Invalid RAR5 UTF-8 member name","messagePattern":"Invalid RAR5 UTF-8 member name","errorType":"exception","errorClass":"ArchiveError","httpStatus":null,"severity":"error","filePath":"packages/utils/src/ar/rar.ts","lineNumber":375,"sourceCode":"\t\t\tlet version = compression & 0x3f;\n\t\t\tif (version === 1 && (compression & 0x100000) !== 0) version = 0;\n\t\t\tconst solid = (compression & 0x40) !== 0;\n\t\t\tconst method = (compression >>> 7) & 7;\n\t\t\tconst dictionaryPower = (compression >>> 10) & 0x1f;\n\t\t\tlet dictionarySize = 128 * 1024 * 2 ** dictionaryPower;\n\t\t\tif ((compression & 0x3f) === 1) dictionarySize += (dictionarySize * ((compression >>> 15) & 0x1f)) / 32;\n\t\t\tif (!Number.isSafeInteger(dictionarySize) || dictionarySize > options.limits.maxInMemorySize) {\n\t\t\t\tthrow new ArchiveError(`RAR5 dictionary is too large (${dictionarySize} bytes)`);\n\t\t\t}\n\t\t\tconst hostOs = readVint(bytes, cursor, extraStart, \"host OS\");\n\t\t\tconst nameSize = readVint(bytes, cursor, extraStart, \"file name size\");\n\t\t\tassertArchivePathBytes(nameSize, \"member path\", options.limits.maxPathBytes);\n\t\t\tneed(cursor.offset, nameSize, extraStart, \"RAR5 file name\");\n\t\t\tlet rawPath: string;\n\t\t\ttry {\n\t\t\t\trawPath = UTF8.decode(bytes.subarray(cursor.offset, cursor.offset + nameSize));\n\t\t\t} catch {\n\t\t\t\tthrow new ArchiveError(\"Invalid RAR5 UTF-8 member name\");\n\t\t\t}\n\t\t\tcursor.offset += nameSize;\n\t\t\tlet linkTarget: string | undefined;\n\t\t\tfor (const extra of readExtraRecords(bytes, extraStart, headerEnd)) {\n\t\t\t\tconst extraCursor = { offset: extra.start };\n\t\t\t\tif (extra.type === 1) throw new ArchiveError(`Encrypted RAR5 member '${rawPath}' is not supported`);\n\t\t\t\tif (extra.type === 3) {\n\t\t\t\t\tconst timeFlags = readVint(bytes, extraCursor, extra.end, \"time flags\");\n\t\t\t\t\tif ((timeFlags & 2) !== 0) {\n\t\t\t\t\t\tif ((timeFlags & 1) !== 0) {\n\t\t\t\t\t\t\tneed(extraCursor.offset, 4, extra.end, \"Unix modification time\");\n\t\t\t\t\t\t\tmtimeMs = readUInt32LE(bytes, extraCursor.offset) * 1000;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tneed(extraCursor.offset, 8, extra.end, \"Windows modification time\");\n\t\t\t\t\t\t\tmtimeMs = filetimeMs(bytes, extraCursor.offset);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if (extra.type === 5) {","sourceCodeStart":357,"sourceCodeEnd":393,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/utils/src/ar/rar.ts#L357-L393","documentation":"The member's file name bytes are decoded as UTF-8 (RAR5 stores names in UTF-8). If the byte range fails UTF-8 validation, the library throws this ArchiveError rather than emitting a record with a corrupted path — usually a sign the file is not a genuine RAR5 archive or is corrupted.","triggerScenarios":"Decoding bytes.subarray(name bytes) with UTF8.decode throws — non-UTF-8 name bytes in a file header, corrupt/truncated data misdetected as RAR5, or a forged header with an invalid nameSize pointing at binary data.","commonSituations":"Corrupted downloads; files with a RAR5-like signature but different inner format; archives damaged in transfer; malicious files crafted to break parsers.","solutions":["Verify the archive integrity (`unrar t archive.rar`) and re-download/re-extract if corrupt","Confirm the file is really RAR5 (`file archive.rar`) and not a renamed archive of another format","If it is a genuine corrupted archive, repair with WinRAR's repair function or `rar r`"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const records = readRar(bytes);\n} catch (err) {\n  if (err instanceof ArchiveError && err.message.includes('Invalid RAR5 UTF-8')) {\n    throw new Error('Archive is corrupt or not a valid RAR5 file');\n  } else throw err;\n}","preventionTips":["Verify checksums of downloaded archives before parsing","Run `unrar t` as a pre-flight integrity check","Treat this error as a corruption signal, not a recoverable path issue"],"tags":["rar5","utf8","corruption","filename"],"backgroundTag":"invalid-utf8-path","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}