ng-text-truncate icon indicating copy to clipboard operation
ng-text-truncate copied to clipboard

not working when text is html

Open ghost opened this issue 11 years ago • 9 comments

seems like there is a problem when the text string contains HTML.

ghost avatar Sep 19 '14 09:09 ghost

Hi michaelmel, what is exactly the problem you found? Do you refer to html tags not being displayed as plain text?

lorenooliveira avatar Sep 21 '14 16:09 lorenooliveira

For some reason, when I tried to use it, HTML got converted into plain text. I could see the HTML code, but it was not rendering as such. Maybe I was doing something wrong?

ghost avatar Sep 21 '14 17:09 ghost

Absolutely michaelmel. Actually, sorry for my typo in the previous message. Where I wrote "Do you refer to html tags not being displayed as plain text?" I actually meant "Do you refer to html tags being displayed as plain text?".

Well, the original goals of this directive didn't include display HTML text as plain text. Do you mind explain what is your use case for truncating text displaying HTML as plain text? I have to think a little bit about how to include this behavior in the directive...

lorenooliveira avatar Sep 22 '14 14:09 lorenooliveira

In my case I display a snipped which contains some basic html tags (like text formatting: b, i, u). Ideally it would be nice know that html is not cut in the middle of the tag. I know it's a lot to ask, and I don't expect it to work perfectly, as the task of making sure there is no problems with html is in app developer's hands.

ghost avatar Sep 22 '14 17:09 ghost

Depending on where the text is coming from, like user provided text that you don't have control of, allowing this to accept/render html tags is potentially allowing XSS attacks on your application, just something to be aware of in case your using this for user content you could get a string from a user like:

"Some filler >script>alert("XSS")>/script> text."

ghost avatar Nov 06 '14 23:11 ghost

Hi, I'm having some trouble if the text is html format. For example, the text is:

This is short text.This is more text

then, the ng-text-truncate generate this code:

This is short text....<span class='btn-link ngTruncateToggleText' ng-click='toggleShow()'ng-show='!open'> Show

This is more text

<span class='btn-link ngTruncateToggleText'ng-click='toggleShow()'> Hide

which is not properly html enclosed. see the matching of

tag.

Both the more and less link will appears when page loads.

Could you give suggestion how to fix this issue?

Thanks!

sh977218 avatar Apr 14 '15 21:04 sh977218

@lorenooliveira I have the same issue as @sh977218

Screenshot - image

Hoping for a quick fix on this one.

harishkotra avatar Apr 24 '15 04:04 harishkotra

same issue here, also if the last charset is a break line you get ; and if you use ng-text-truncate="longtext | linky:'_blank'" and the link is exactly in the limit of characters you get that strange behavior

octavioamu avatar Jul 23 '15 15:07 octavioamu

$scope.longText = $scope.longText.replace('

', '').replace('

',
);

santoshanand avatar Apr 11 '17 04:04 santoshanand