html-sanitizing

Can you use Angular Binding Expression inside HTML retrieved from Service?

杀马特。学长 韩版系。学妹 提交于 2019-12-10 17:57:33
问题 I have a html snippet that comes from a mongo db retrieved by an angular service. This html snippet is then sanitized on my page using the ng-bind-html directive from ngSanitize. I am wondering how I can bind an expression inside the html snippet to the page, so that when I bind the html the binding expression is executing inside the snippet. For example, here is my div where my html snippet will be bound to: <div ng-bind-html="middle_snippet"> </div> and here is the actual snippet that gets

How to undo bypassSecurityTrustHtml, i.e convert SafeValue back to string

℡╲_俬逩灬. 提交于 2019-12-08 01:50:51
问题 I am generating html, and inserting it into my web page using let data = '<font color=blue>hello world</font>'; this.safevalue = this.domSanitizer.bypassSecurityTrustHtml(data); Elsewhere in my code I want to convert the safe value back into a string, so I tried this... data = this.safevalue.toString(); but this sets data to a string like this... 'SafeValue must use [property]=binding: (see http://g.co/ng/security#xss)' which is not helpful 回答1: I don't know if you already found a fix for

Javascript sanitization: The most safe way to insert possible XSS html string

淺唱寂寞╮ 提交于 2019-12-07 04:40:56
问题 Currently i'm using this method with jQuery solution, to clean string from possible XSS attacks. sanitize:function(str) { // return htmlentities(str,'ENT_QUOTES'); return $('<div></div>').text(str).html().replace(/"/gi,'"').replace(/'/gi,'&apos;'); } But i have a feeling it's not safe enough. Do i miss something? I have tried htmlentities from phpjs project here: http://phpjs.org/functions/htmlentities:425/ But it's kinda bugged and returns some additional special symbols. Maybe it's an old

Why is the `NAME` attribute considered unsafe?

最后都变了- 提交于 2019-12-06 13:55:55
问题 I'm passing user-generated HTML into a database and I'm trying to make sure that no malicious code is passed through. One of the steps I'm taking is to run passed code through pear's HTML_Safe class to remove vulnerable markup. However, one thing I've noticed is that the name attribute of submitted elements gets removed. Sure enough, when you look at the source code, name is one of the few attributes that's blacklisted by default: http://pear.php.net/package/HTML_Safe/docs/latest/HTML_Safe

How to undo bypassSecurityTrustHtml, i.e convert SafeValue back to string

流过昼夜 提交于 2019-12-06 05:46:58
I am generating html, and inserting it into my web page using let data = '<font color=blue>hello world</font>'; this.safevalue = this.domSanitizer.bypassSecurityTrustHtml(data); Elsewhere in my code I want to convert the safe value back into a string, so I tried this... data = this.safevalue.toString(); but this sets data to a string like this... 'SafeValue must use [property]=binding: (see http://g.co/ng/security#xss)' which is not helpful I don't know if you already found a fix for this, but, if you just want the original value, marked as safe: var yourString = this.domSanitizer.sanitize

Javascript sanitization: The most safe way to insert possible XSS html string

做~自己de王妃 提交于 2019-12-05 09:46:53
Currently i'm using this method with jQuery solution, to clean string from possible XSS attacks. sanitize:function(str) { // return htmlentities(str,'ENT_QUOTES'); return $('<div></div>').text(str).html().replace(/"/gi,'"').replace(/'/gi,'&apos;'); } But i have a feeling it's not safe enough. Do i miss something? I have tried htmlentities from phpjs project here: http://phpjs.org/functions/htmlentities:425/ But it's kinda bugged and returns some additional special symbols. Maybe it's an old version? For example: htmlentities('test"','ENT_QUOTES'); Produces: test&quot; But should be: test" How

Angular 2: sanitizing HTML stripped some content with div id - this is bug or feature?

限于喜欢 提交于 2019-12-02 20:28:57
I use <div [innerHTML]="body"></div> to pass unescaped HTML to my template, and when I pass to body div with attribute id , Angular throw: WARNING: sanitizing HTML stripped some content (see http://g.co/ng/security#xss ). WARNING: sanitizing HTML stripped some content (see http://g.co/ng/security#xss ). WARNING: sanitizing HTML stripped some content (see http://g.co/ng/security#xss ). See. plunker So why it says this? What can be dangerous id in div ? Could this bug? Ced It is because id attribute is not safe. This is not my answer but it will answer your question : https://security

Ruby Regex to capture everything between two strings (inclusive)

此生再无相见时 提交于 2019-12-02 07:11:50
问题 I'm trying to sanitize some HTML and just remove a single tag (and I'd really like to avoid using nokogiri, etc). So I've got the following string appearing I want to get rid of: <div class="the_class>Some junk here that's different every time</div> This appears exactly once in my string, and I'd like to find a way to remove it. I've tried coming up with a regex to capture it all but I can't find one that works. I've tried /<div class="the_class">(.*)<\/div>/m and that works, but it'll also

Ruby Regex to capture everything between two strings (inclusive)

为君一笑 提交于 2019-12-02 01:45:09
I'm trying to sanitize some HTML and just remove a single tag (and I'd really like to avoid using nokogiri, etc). So I've got the following string appearing I want to get rid of: <div class="the_class>Some junk here that's different every time</div> This appears exactly once in my string, and I'd like to find a way to remove it. I've tried coming up with a regex to capture it all but I can't find one that works. I've tried /<div class="the_class">(.*)<\/div>/m and that works, but it'll also match up to and including any further </div> tags in the document, which I don't want. Any ideas on how

Twig: Allow HTML, but escape script

半腔热情 提交于 2019-12-02 01:34:57
问题 I am investigating a possible XSS attack vector for my application. What I have: FormType with a single textarea field. Normally this field can contain html tags. Twig template that renders the data inserted. I use that form to insert the following content: <b>Some valid HTML text</b> <script type="text/javascript">alert("XSS")</script> Viewing that data would require escaping. I am familiar with few strategies when it comes to escaping the data. 1) raw filter: Completely disables escaping ->