i18n icon indicating copy to clipboard operation
i18n copied to clipboard

fix: shouldn't htmlEntities and htmlNumbers pass ?

Open signavio-fghedina opened this issue 3 years ago • 2 comments

Just by chance I looked at this pr when was opened and I asked myself whether or not the escapeHtml should ignore htmlEntities and htmlNumbers

this would mean no transformation for those occurrences when using markdown: true, which makes a lot of sense to my eyes

in case it actually should behave like that, this pr fixes it accordingly, changing the bare minimum. actually that function could also be reduced to

export function escapeHtml(unsafe = ''){
  const htmlEscapes = {
    	'&': '&',
    	'<': '&lt;',
    	'>': '&gt;',
    	'"': '&quot;',
    	"'": '&#039;',
  	}
  const rxt = /&(?![\w\#]+;)|[<>"']/g
  const rx = new RegExp(rxt);
  return rx.test(unsafe)
    ? unsafe.replace(rxt, e => htmlEscapes[e])
  	: unsafe
}

please let me know your thoughts on that

signavio-fghedina avatar Feb 02 '22 14:02 signavio-fghedina

@signavio-fghedina is this PR still valid and needed or may it be closed?

marpme avatar Sep 08 '22 05:09 marpme

@signavio-fghedina is this PR still valid and needed or may it be closed?

@marpme I think it is still valid implementation wise. Up to you, I wont mind if u close it 🤷‍♂️

signavio-fghedina avatar Sep 09 '22 14:09 signavio-fghedina