From dafd7219258a9e82fa1f1d63049d77a4770ef595 Mon Sep 17 00:00:00 2001 From: Casper Warden <216465704+casperwardensl@users.noreply.github.com> Date: Mon, 23 Nov 2020 11:59:44 +0000 Subject: [PATCH] Fix issue with notecard assets not passing LL's verifier --- lib/classes/LLLindenText.ts | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/lib/classes/LLLindenText.ts b/lib/classes/LLLindenText.ts index fda541f..9eb7ec8 100644 --- a/lib/classes/LLLindenText.ts +++ b/lib/classes/LLLindenText.ts @@ -2,7 +2,7 @@ import { InventoryItem } from './InventoryItem'; export class LLLindenText { - version: number = 2; + version = 2; private lineObj: { lines: string[], @@ -91,28 +91,25 @@ export class LLLindenText lines.push('Linden text version ' + this.version); lines.push('{'); const count = Object.keys(this.embeddedItems).length; - if (count > 0) + lines.push('LLEmbeddedItems version 1'); + lines.push('{'); + lines.push('count ' + String(count)); + for (const key of Object.keys(this.embeddedItems)) { - lines.push('LLEmbeddedItems version 1'); lines.push('{'); - lines.push('count ' + String(count)); - for (const key of Object.keys(this.embeddedItems)) - { - lines.push('{'); - lines.push('ext char index ' + key); - lines.push('\tinv_item\t0'); - lines.push(this.embeddedItems[parseInt(key, 10)].toAsset('\t')); - lines.push('}'); - } + lines.push('ext char index ' + key); + lines.push('\tinv_item\t0'); + lines.push(this.embeddedItems[parseInt(key, 10)].toAsset('\t')); lines.push('}'); } - lines.push('Text length ' + String(Buffer.byteLength(this.body))); - lines.push(this.body + '}\n\0'); + lines.push('}'); + lines.push('Text length ' + String(Buffer.byteLength(this.body, (this.version === 1) ? 'ascii' : 'utf-8'))); + lines.push(this.body + '}'); if (this.version === 1) { - return Buffer.from(lines.join('\n'), 'ascii'); + return Buffer.from(lines.join('\n') + '\n', 'ascii'); } - return Buffer.from(lines.join('\n'), 'utf-8'); + return Buffer.from(lines.join('\n') + '\n', 'utf-8'); } private parseEmbeddedItems()