user-input

How can I safely use regexes from user input?

My (Perl-based) application needs to let users input regular expressions, to match various strings behind the scenes. My plan so far has been to take the string and wrap it in something like $regex = eval { qr/$text/ }; if (my $error = $@) { # mangle $error to extract user-facing message ($text having been stripped of newlines ahe...

Multiple Key Gestures for custom keyboard shortcuts in WPF

Does anyone know if it's possible to have key combinations for keyboard shortcuts in WPF? Right now if I want to use CTRL + S as a shortcut I can do the following: InputGestures.Add( new KeyGesture( Key.S , ModifierKeys.Control )); But if I want to use CTRL + S, D ... I don't have an overload that takes the "D". Is there a way to ov...

Safely prompt for yes/no with cin

I'm in an intro to C++ class and I was wondering of a better method of checking if input was the desired type. Is this a good way of doing this? I come from a PHP/PERL background which makes me rather apprehensive of using while loops. char type; while (true) { cout << "Were you admitted? [y/n]" << endl; cin >> type; if (...

ASP.NET Multiline textbox allowing input above UTF-8

In my web.config I have <globalization fileEncoding="utf-8" requestEncoding="utf-8" responseEncoding="utf-8" culture="en-US" uiCulture="de-DE" /> In my page directive I have ResponseEncoding="utf-8" Yet for some reason an ASP TextBox with the TextMode="MultiLine" allows inputs of characters outside of UTF-8. When I paste...

Fix a character to text input box using javascript/jquery

I am looking for a way to 'fix' a dollar symbol $ to a text input box eg <input type="text" value="$" /> but make it not possible for the default value to be removed, so that whatever the user inputs, there is always a $ symbol 'prepending' input. Cheers ...

How to handle user input with a mixture of HTML and punctuation?

I have a form field that includes a mixture of HTML and text. I want users to be able to use basic HTML and punctuation. Currently I am using mysql_real_escape_string and preg_replace to sanitise the data and insert it into the database. My understanding is that preg_replace is the best way to strip any characters that are not in a whit...

pyserial- sending in parameters at runtime- input vs. raw_input - security flaw?

Hello, I am writing a program that opens and records data sent through a serial port into a text file. I am currently adding functionality to allow reconfiguring the serial port during run-time. I prompt the user to choose which variable to change one at a time, so as to keep it simple for myself (i would appreciate elegant solutions as...

JS/jQuery - Displaying results based upon user input

Hey all, I've been thinking about this project I've taken on, now what I am after is a form that will have a list of questions, simple yes/no questions that when answered and submitted it will dynamically return the relevant data on that same page. So initially all answers will be loaded onto the page then hidden, and the way I plan on ...

Enforce numbers in mobile web form

I have a simple webform targeted for Opera Mini and Opera Mobile. I'm using just a HTML input element. Now I would like to restrict the element to only have integer numbers. Is there a way to enforce this in this browser (possible even that the phone will have it's number mode on when entering the form)? And if I wanted to allow floats...

How do I strip quotes from an input box using PHP

I have this: <input name="title" type="text" class="inputMedium" value="' . $inputData['title'] . '" /> I want to strip quotes from user input so that if someone enters something like: "This is my title" it wont mess up my code. I tried this and it's not working: $inputData['title'] = str_replace('"', '', $_POST['title']); ...

Best method for selecting multiple checkbox items

I am developing an internal messaging application which is to be used by approximately 500 users. When composing a new message it will ask who you want to send the message to. Instead of presenting the user with a checkbox list of 500 users which they can pick from (i.e they may only wish to send to 20-30 of the 500 users) I wanted to as...

C++ Unwanted infinite while loop

I get an infinite loop when I use the following code in C++ and I don't understand why. I suspect the problem is within the input_words() function. Here is the code: #include<iostream> using namespace std; string input_words(int maxWords) { int nWord = 0; string words[maxWords]; string aWord = ""; while (aWord != "Quit"...

User input filtering - do I need to filter HTML?

Hello all. Note: I take care of SQL injection and output escaping elsewhere - this question is about input filtering only, thanks. I'm in the middle of refactoring my user input filtering functions. Before passing the GET/POST parameter to a type-specific filter with filter_var() I do the following: check the parameter encoding with ...

Any way to have a schema use user-defined elements in its structure?

I'm wondering if it's possible to have a schema use user-defined elements (from the XML) for its structure. As in, as a user, I would be able to have something like: <subjectType> <name>plane</name> <name>bird</name> </subjectType> <questionType> <name>organic</name> <name>awesome</name> </questionType> <subjectInterview su...

C - Reading user input

Hello everyone, I have a program where user input is required, a user types in a number 1-8 to determine how to sort some data, but if the user just hits enter a different function is performed. I get the general idea of how to do this and I thought what I had would work just fine but I'm having some issues when it comes to when the us...

Question about input data that should not be assumed except that there is one white space.

I'm writing a program that asks the user to enter their birth date. For it, I'm not suppose to know how the numeric data is to be enter except that there is one white space between the month, day and year. Right now, I have it reading the date as a String on one line and I am unsure how to do it so it meets the specifications of the prog...

Java: Finding birthdate on different planets

I'm writing a program that asks the user for their birthdate and then calculates that birthdate on different planets. I am not suppose to assume how the birthdate is to be enter except that there is one white space between each number. The code I have right now does not meet these specifications right now and I'm not sure how to write i...

Displaying user input on my page

In our application, we allow user's to write their Bio using a WYSIWYG editor, but it often contains bad HTML that breaks our page. Is it a good idea to show the user bio inside an iframe so it doesn't affect the rest of the page? Or any better options? Thanks ...

How do you write a ksh script that automatically fills in user input?

Is there any way to automate the user input in a ksh script? I realize that in many instances you can create an expect script to do exactly what I am saying, but expect is not installed on the server and there is no chance of that occurring in the near future. But I still need a method of automating user input so the only reaction requ...

Is there a way to identify forms if using the button element to submit?

I've started using the button element to submit my forms <button type="submit">Send</button> I know if I used an input element like so, I could easily determine in PHP which form was submitted (by reading the value of $_POST['form'] in the example below). <input type="submit" value="Send" name="form" value="contact" /> Is there a ...