fusion-core icon indicating copy to clipboard operation
fusion-core copied to clipboard

Document or expose additional information for escaped HTML strings

Open KevinGrandon opened this issue 5 years ago • 0 comments

Right now when a developer performs console.log() on a string escaped by the html method in fusion-core, it's logged as an empty object. This makes it pretty confusing, so it would be nice if

At a minimum we should have some more comments in sanitization.js. It would be nice if we could expose some additional information as enumerable keys, possibly nesting the object? Quick sketch:

    const obj = {
         description: "An escaped HTML value. Use consumeSanitizedHTML to output."
    };
    Object.defineProperty(obj, key, {
      enumerable: false,
      configurable: false,
      value: head + values.map((s, i) => escape(s) + rest[i]).join(''),
    });
return obj;

https://github.com/fusionjs/fusion-core/blob/a6145ba841f794ac220df5ad02065abf99962daf/src/sanitization.js#L36-L42

KevinGrandon avatar Aug 26 '18 03:08 KevinGrandon