sanitize

Using sanitize within a Rails controller

旧巷老猫 提交于 2019-11-30 01:42:26
I'm trying to call sanitize within a controller. Here's what I tried: class FooController < ApplicationController include ActionView::Helpers::SanitizeHelper # ... end However, I'm getting this error: undefined method `white_list_sanitizer' for FooController:Class I searched around and people recommended switching the include line to include ActionView::Helpers , but that results in this error: undefined method `url_for' for nil:NilClass What's the correct way to call sanitize ? I'm using Rails 2.3.5. you can use this ActionController::Base.helpers inside action method: class SiteController <

Using sanitize within a Rails controller

好久不见. 提交于 2019-11-28 22:27:36
问题 I'm trying to call sanitize within a controller. Here's what I tried: class FooController < ApplicationController include ActionView::Helpers::SanitizeHelper # ... end However, I'm getting this error: undefined method `white_list_sanitizer' for FooController:Class I searched around and people recommended switching the include line to include ActionView::Helpers , but that results in this error: undefined method `url_for' for nil:NilClass What's the correct way to call sanitize ? I'm using

Using Wordpress, can some one tell me the best way of sanitizing input?

落爺英雄遲暮 提交于 2019-11-28 19:40:09
I'm developing an application using Wordpress as a CMS. I have a form with a lot of input fields which needs to be sanitized before stored in the database. I want to prevent SQL injection, having javascript and PHP code injected and other harmful code. Currently I'm using my own methods to sanitize data, but I feel that it might be better to use the functions which WP uses. I have looked at Data Validation in Wordpress, but I'm unsure on how much of these functions I should use, and in what order. Can anyone tell what WP functions are best to use? Currently I'm "sanitizing" my input by doing

Sanitize user input in bash for security purposes

江枫思渺然 提交于 2019-11-28 17:29:53
How do I sanitise user input in a bash script so that I can then pass it as an argument to another shell program? I want to prevent the following: INPUT="filename;rm -rf /" ls $INPUT I was thinking it should be enough to surround the user input in double quotes like so: ls "$INPUT" but what if there is a double quote in $INPUT ? Or does bash already deal with this problem? The Short Bash already deals with that. Quoting it is sufficient. ls "$INPUT" The Long A rough guide to how the shell parses this line is: "ls \"$INPUT\"" # Raw command line. ["ls", "\"$INPUT\""] # Break into words. ["ls", "

Escape non HTML tags in plain text (convert plain text to HTML)

江枫思渺然 提交于 2019-11-28 14:46:43
Using Rails, I need to get a plain text and show it as HTML, but I don't want to use <pre> tag, as it changes the format. I needed to subclass HTML::WhiteListSanitizer to escape non whitelisted tags (by changing process_node ), monkey patch HTML::Node to don't downcase tags' names and monkey patch HTML::Text to apply <wbr /> word splitting: class Text2HTML def self.convert text text = simple_format text text = auto_link text, :all, :target => '_blank' text = NonHTMLEscaper.sanitize text text end # based on http://www.ruby-forum.com/topic/87492 def self.wbr_split str, len = 10 fragment = /.{#

What's up with these Unicode combining characters and how can we filter them?

醉酒当歌 提交于 2019-11-28 02:48:49
กิิิิิิิิิิิิิิิิิิิิ ก้้้้้้้้้้้้้้้้้้้้ ก็็็็็็็็็็็็็็็็็็็็ ก็็็็็็็็็็็็็็็็็็็็ กิิิิิิิิิิิิิิิิิิิิ ก้้้้้้้้้้้้้้้้้้้้ ก็็็็็็็็็็็็็็็็็็็็ กิิิิิิิิิิิิิิิิิิิิ ก้้้้้้้้้้้้้้้้้้้้ กิิิิิิิิิิิิิิิิิิิิ ก้้้้้้้้้้้้้้้้้้้้ ก็็็็็็็็็็็็็็็็็็็็ ก็็็็็็็็็็็็็็็็็็็็ กิิิิิิิิิิิิิิิิิิิิ ก้้้้้้้้้้้้้้้้้้้้ ก็็็็็็็็็็็็็็็็็็็็ กิิิิิิิิิิิิิิิิิิิิ ก้้้้้้้้้้้้้้้้้้้้ These recently showed up in facebook comment sections. How can we sanitize this? What's up with these unicode characters? That's a character with a series of combining characters . Because the combining

C# Sanitize File Name

大憨熊 提交于 2019-11-27 16:56:22
I recently have been moving a bunch of MP3s from various locations into a repository. I had been constructing the new file names using the ID3 tags (thanks, TagLib-Sharp!), and I noticed that I was getting a System.NotSupportedException : "The given path's format is not supported." This was generated by either File.Copy() or Directory.CreateDirectory() . It didn't take long to realize that my file names needed to be sanitized. So I did the obvious thing: public static string SanitizePath_(string path, char replaceChar) { string dir = Path.GetDirectoryName(path); foreach (char c in Path

Sanitize input in Angular2 [duplicate]

走远了吗. 提交于 2019-11-27 08:02:59
This question already has an answer here: Angular HTML binding 18 answers I am trying to get third-party (potentially unsafe) html content from my database and insert it into my html document. How do I safely do that (Protection against XSS) ? In Angular1.x there used to be $sce to sanitize input, how do I do that in Angular2 ? As far as I understand, Angular2 automatically sanitizes it by default, is that correct ? Something like this will not work: <div class="foo"> {{someBoundValueWithSafeHTML}} // I want HTML from db here </div> To insert normal HTML into your angular2 app, you can use the

Safely sandbox and execute user submitted JavaScript?

空扰寡人 提交于 2019-11-27 06:48:33
I would like to have the ability to let users submit arbitrary JavaScript code, which is then sent to a Node.JS server and safely executed before the output is sent back to multiple clients (as JSON). The eval function comes to mind, but I know this has multiple security concerns (the user submitted code would be able to access Node's File API, etc). I have seen some projects like Microsoft Web Sandbox and Google Caja which allow execution of sanitized markup and script (for embedding third-party ads on websites), but it seems that these are client-side tools and I'm not sure if they can be

PHP Sanitize Data

让人想犯罪 __ 提交于 2019-11-27 01:39:21
问题 I am new to the world of coding and PHP hence would like to learn what's the best way to sanitize form data to avoid malformed pages, code injections and the like. Is the sample script I found below a good example? Code originally posted at http://codeassembly.com/How-to-sanitize-your-php-input/ /** * Sanitize only one variable . * Returns the variable sanitized according to the desired type or true/false * for certain data types if the variable does not correspond to the given data type. * *