spaceshelter / orbitar

Experimental collective social/blogging platform with self-regulation.
MIT License
59 stars 23 forks source link

Fix malformed url parsing #342

Closed Aivean closed 1 year ago

Aivean commented 1 year ago

Parser fails when testing malformed URLs for validity.

Minimal test:

<a href="https://test>test</a>%<img src="https://test"/>

Produces:

URI malformed
URIError: URI malformed
    at decodeURI (<anonymous>)
    at TheParser.validUrl (orbitar/backend/src/parser/TheParser.ts:444:26)
    at TheParser.parseA (orbitar/backend/src/parser/TheParser.ts:357:19)
    at a (orbitar/backend/src/parser/TheParser.ts:43:31)
    at TheParser.parseNode (orbitar/backend/src/parser/TheParser.ts:112:24)
    at TheParser.parseChildNodes (orbitar/backend/src/parser/TheParser.ts:91:30)
    at TheParser.parse (orbitar/backend/src/parser/TheParser.ts:73:34)
    at Object.<anonymous> (orbitar/backend/test/parser/TheParser.test.ts:336:11)
    at Promise.then.completed (orbitar/backend/node_modules/jest-circus/build/utils.js:333:28)
    at new Promise (<anonymous>)