UI: Separating Multiple Inputs With Comma - flask

I am wondering how to achieve this with Flask and WTForms for UI purposes. This input takes up to 10 responses separated by comma. enter image description here
I hope for each response to be cemented in the input after the user types in a comma for UI purposes (I can handle it on the backend). So for example, they type in "Red," and "Red" is cemented in the input with the ability to delete it. Any library suggestions or ideas on how I should attack this?

You would need JavaScript to do this. This question might be of some help: Dynamically check text input. I would do a search on dynamically checking text input.

Related

How to write tab command in c++ to switch input form

I have a database and I want to add that data to a web application using ditto. I copied the data from my domain for me to paste in someone else's domain. With a semicolon separator.
So, I want when the text is pasted, the semicolon changes to the tab command to the next input form. Please help.
Description is in the image in the attachment. Thank you.
DITTO SCRIPT
INPUT FORM
You could try using a vector as a buffer if you're working with ascii characters. just do the same comparisons with a for each loop.

Gimp plugin in C++ : how to have an input from the user?

I would like to make a watermark plugin in GIMP. I need to have the text of the watermark as input from the user. I'll try with g_message but it is not working: I can't read an input from user in the plugin.
Can you help?
Best regards.
Jean.
I assume your plug in already runs and "just" needs to have the possibility to ask the user to provide a string. The easiest solution would be to add a string as input parameter - this way GIMP takes care about showing the dialog to the user before calling your script. This can be done via the gimp_install_procedure(...) call that I assume you are using, specifically the params parameter of this function: This is an array of GimpParamDef structs where you specify the type (PF_STRING), name ("text") and description ("text of watermark") of your input parameter.

How to sanitize form values to allow text-only

I understand that if a user needs to supply HTML code as part of a form input (e.g. in a textarea) then I use an Anti-Samy policy to filter out the hazardous HTML that's not permitted.
However, I have some text-fields and text-areas which should be text-only. No HTML code at all should be inserted into the DB from these fields.
I am trying to therefore sanitize the inputs so that only raw text is inserted into the database. I believe I can do this two ways:
Use a Regex expression to filter out HTML code e.g. #REReplaceNoCase(FORM.InputField, "[^a-zA-Z\d\s:]", "", "ALL")#
Use a strict text-only Anti-Samy policy
Which option is the correct/good-practice way to remove any user inputted HTML code from a textfield. Or are there further options available to me?
While you could use AntiSamy to do it, I don't know how sensible that would be. Kinda defeats the purpose of it's flexibility, I think. I'd be curious about the overhead, even if minimal, to running that as a filter over just a regex.
Personally I'd probably opt for the regex route in this scenario. Your example appears to only strip the brackets. Is that acceptable in your situation? (understandable if it was just an example) Perhaps use something like this:
reReplace(string, "<[^>]*>", "", "ALL");

Imacros: input random var from extraction

I have a working imacros script that extracts 3 urls from a page, creates variables from them, moves on to a different page and then inputs one of the variables into a form. Right now I just hardcode {{!VAR1}}, but what I would like to do is make the input random from the three variables. So instead of this:
CONTENT={{!VAR1}}
I would like to have either {{!VAR1}} or {{!VAR2}} or {{!VAR3}} be the input randomly.
Is this possible?
Yes. Use JavaScript scripting http://wiki.imacros.net/Web_Scripting
With use of JavaScript you can find some random functions do this.

Cleansing string / input in Coldfusion 9

I have been working with Coldfusion 9 lately (background in PHP primarily) and I am scratching my head trying to figure out how to 'clean/sanitize' input / string that is user submitted.
I want to make it HTMLSAFE, eliminate any javascript, or SQL query injection, the usual.
I am hoping I've overlooked some kind of function that already comes with CF9.
Can someone point me in the proper direction?
Well, for SQL injection, you want to use CFQUERYPARAM.
As for sanitizing the input for XSS and the like, you can use the ScriptProtect attribute in CFAPPLICATION, though I've heard that doesn't work flawlessly. You could look at Portcullis or similar 3rd-party CFCs for better script protection if you prefer.
This an addition to Kyle's suggestions not an alternative answer, but the comments panel is a bit rubbish for links.
Take a look a the ColdFusion string functions. You've got HTMLCodeFormat, HTMLEditFormat, JSStringFormat and URLEncodedFormat. All of which can help you with working with content posted from a form.
You can also try to use the regex functions to remove HTML tags, but its never a precise science. This ColdFusion based regex/html question should help there a bit.
You can also try to protect yourself from bots and known spammers using something like cfformprotect, which integrates Project Honeypot and Akismet protection amongst other tools into your forms.
You've got several options:
"Global Script Protection" Administrator setting, which applies a regular expression against post and get (i.e. FORM and URL) variables to strip out <script/>, <img/> and several other tags
Use isValid() to validate variables' data types (see my in depth answer on this one).
<cfqueryparam/>, which serves to create SQL bind parameters and validate the datatype passed to it.
That noted, if you are really trying to sanitize HTML, use Java, which ColdFusion can access natively. In particular use the OWASP AntiSamy Project, which takes an HTML fragment and whitelists what values can be part of it. This is the same approach that sites like SO and slashdot.org use to protect submissions and is a more secure approach to accepting markup content.
Sanitation of strings in coldfusion and in quite any language is very important and depends on what you want to do with the string. most mitigations are for
saving content to database (e.g. <cfqueryparam ...>)
using content to show on next page (e.g. put url-parameter in link or show url-parameter in text)
saving files and using upload filenames and content
There is always a risk if you follow the idea to prevent and reduce a string by allow basically everything in the first step and then sanitize malicious code "away" by deleting or replacing characters (blacklist approach).
The better solution is to replace strings with rereplace(...) agains regular expressions that explicitly allow only the characters needed for the scenario you use it as an easy solution, whenever this is possible. use cases are inputs for numbers, lists, email-addresses, urls, names, zip, cities, etc.
For example if you want to ask for a email-address, you could use
<cfif reFindNoCase("^[A-Z0-9._%+-]+#[A-Z0-9.-]+\.(?:[A-Z]{5})$", stringtosanitize)>...ok, clean...<cfelse>...not ok...</cfif>
(or an own regex).
For HTML-Imput or CSS-Imput I would also recommend OWASP Java HTML Sanitizer Project.