Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String &lt; and &gt; characters after clamp with custom HTML will convert to <> #52

Open
zmeiPop opened this issue Apr 8, 2016 · 0 comments

Comments

@zmeiPop
Copy link

zmeiPop commented Apr 8, 2016

Using clamp for displaying list of emails (chrome). Email format is a standard outlook format

Smith, John (EY123987) <john[email protected]>; Simpson, Homer (EY123987) <homer[email protected]>...

Clamp replace &lt; with <, and browser understands it as a HTML element, thus loosing text <[email protected]>

Issue is on this line

element.innerHTML = target.nodeValue + ' ' + truncationHTMLContainer.innerHTML + opt.truncationChar;

I have applied a fix on local copy of clamp.js file

element.innerHTML = escapeHtml(target.nodeValue) + ' ' + truncationHTMLContainer.innerHTML + opt.truncationChar;

Where escapeHtml is

function escapeHtml(unsafe) {
            return unsafe
                 .replace(/&/g, "&amp;")
                 .replace(/</g, "&lt;")
                 .replace(/>/g, "&gt;")
                 .replace(/"/g, "&quot;")
                 .replace(/'/g, "&#039;");
        }

Please fix it in a main version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant