diff --git a/plugins/promptfoo/src/parsers/burp-entities.test.ts b/plugins/promptfoo/src/parsers/burp-entities.test.ts new file mode 100644 index 0000000..cb11249 --- /dev/null +++ b/plugins/promptfoo/src/parsers/burp-entities.test.ts @@ -0,0 +1,23 @@ +import { describe, expect, it } from 'vitest'; + +import { parseBurpSingle } from './burp.js'; + +describe('parseBurpSingle XML entity decoding', () => { + it('decodes ampersands after other entities', () => { + const parsed = parseBurpSingle(` + + + https://example.com/search?note=&quot; + example.com + 443 + https + GET + /search?note=&quot; + + + + `); + + expect(parsed.raw).toContain('note="'); + }); +}); diff --git a/plugins/promptfoo/src/parsers/burp.ts b/plugins/promptfoo/src/parsers/burp.ts index b3c9a27..96eaba2 100644 --- a/plugins/promptfoo/src/parsers/burp.ts +++ b/plugins/promptfoo/src/parsers/burp.ts @@ -122,9 +122,9 @@ function decodeXmlEntities(str: string): string { return str .replace(/</g, '<') .replace(/>/g, '>') - .replace(/&/g, '&') .replace(/"/g, '"') - .replace(/'/g, "'"); + .replace(/'/g, "'") + .replace(/&/g, '&'); } /**