user-input

Location Search - Google Maps

Does anyone have any suggestions on implementing a location search similar to that provided by google maps. Correctly parsing different geographic user inputs. Some examples would be City, State, Country City, State, Zipcode City, Zipcode I lot of directory sites use auto complete to avoid incorrect user input and aren't as intelli...

Processing email with a server application

I'm afraid this is a very generic question, but unfortunately my question is exactly how to get down to the 'specifics' on this particular issue. Let me be more specific: I want to create an "email listener" application - something that would run in my server, so that users could send email to a particular address and this application w...

Whitelist in php

I have an input for users where they are supposed to enter their phone number. The problem is that some people write their phone number with hyphens and spaces in them. I want to put the input trough a filter to remove such things and store only digits in my database. I figured that I could do some str_replace() for the whitespaces and ...

What is the correct way to make web form input safe for a variety of contexts?

What do you all think is the correct (read: most flexible, loosely coupled, most robust, etc.) way to make user input from the web safe for use in various parts of a web application? Obviously we can just use the respective sanitization functions for each context (database, display on screen, save on disk, etc.), but is there some gener...

How do I unit test a console input class?

In one of my applications I have a class which is responsible for user input. The default method of input is the console (keyboard), and I want to write some unit tests for it to make sure it is correct. I am considering using the google-test framework for my unit testing, which makes it easy to automate all the testing. However, I ...

Regular expression transformation for wiki-like mark-up

Consider the following mark-up input: * Line 1 * Line 2 :* Line 2.1 :* Line 2.2 * Line 3 This is typically coded as: <ul> <li>Line 1</li> <li>Line 2</li> <ul> <li>Line 2.1</li> <li>Line 2.2</li> </ul> <li>Line 3</li> </ul> My questions: What would be a good representation for the same input u...

How to preform whitelist-based CSS filtering in PHP

I am working on a site and I would like to make a user able to enter custom CSS into that will be publicly displayed. However, seeing as a good deal of XSS attacks can be preformed through CSS, I would like to be able to find a way to "clean" the CSS output, similar to how HTML Purifier works, by parsing the CSS, running the parsed CSS ...

Can TDD be a valid alternative to overkill data validation?

Consider these two data validation scenarios: Check everything everywhere Make sure that every method that takes one or more arguments actually checks them to ensure that they're syntactically valid. Pros Very fine check granularity. If the code that is being written is for some kind of library we make sure to limit the damage that ...

How to read input character by character/number by number in C?

I have a text file that might contain thousands and thousands of numbers(0-9 --> single digit)/characters, like: 13612371029301276312357829031029352131265309182765236728726355263789120938728...(goes on like this) In C, how do I read them into an array such that each number gets stored separately? I mean after storing, array[0]=1 array[...

Nesting Inputbox If Statements

This is probably a simple question, but if I need to collect data at the start of a sub, using several input boxes, which one of these is the right way? Example 1: InputText1 = InputBox("Enter your name") If InputText1 = "" Then Exit Sub InputText2 = InputBox("Enter your age") If InputText2 = "" Then Exit Sub 'Do something Exampl...

Input on same line as output in c#?

For example: C:\>Input a number: 60 Where the output would be "Input a number: " and the input would be "60". How do I get these to be on the same line? EDIT: The problem that I'm having is that when I output "Input a number: " it automatically starts a new line, so the user inputs "60" underneath (on the next line) ...

Shotgun vs Sequential Input Layout

I would like to determine which of the two layouts below is the better layout. I would like usability to be the main concern. Which one is better (in terms of usability) and why is it better? Shotgun Use as much of the horizontal screen width as possible without causing horizontal scrolling to occur. Obvious benefit is that vertical sc...

Parsing impossible dates in C#

Is there an elegant way to be permissive in date input in C# to accommodate user input like '2009-09-31' (e.g. September 31, which doesn't exist and causes DateTime.Parse to choke)? Ideally I would like to parse this as October 1 (e.g. latest possible date plus overflow). ...

Securing user-data - for use in method calls, SQL and file calls

I am using $_GET, $_POST and $_COOKIE variables in method calls, SQL queries and file calls - and it is necessary to escape / rewrite this user-data for better security (avoid injection attacks and the like). How would you recommend this is done? Some ideas from built-in escape function ... to get the juices flowing: Add backslashes t...

Collecting a huge amount of data on a webform, best methods?

Hey all, I need to allow users to choose/input authors associated with a given publication and there could be just a single author or (43 = the most I have seen so far) up to 40+. Needless to say creating a static form to collect the data will not do since there is no way to know ahead of time how many authors there are. My original ...

How to get the last key pressed without stopping the C programm ?

Writing an application with command line interface and I would like to know at any time if F1 or esc or an arrow key is pressed. What is the simplest way of doing this. I would like to avoid using readline type library. Edited: Linux specific question. It is not multithreaded ...

Escaping ampersands inputted by users through text fields?

Like almost all apps today, I have users who enter various information through standard text inputs. My app is running on Rails. It's a no-brainer to escape ampersands that I include as part of the site copy, etc. But how do I escape an ampersand that is dynamically inputted by a user? Currently, it's totally breaking my frontend...

python - get a key press from the linux command line without having to press enter

I'm writing a command line python programme on linux. I want to ask the user to press a single key, and then it should return that key press. I don't want them to have to press enter, so I can't use the builtin raw_input() method. ...

task kill command does not work for c# app

I have c# winform bug: when the application is waiting for user input yes/no/cancel taskkill command line does not work. Any idea? ...

how to make the Textbox to allow only three digits with three decimal points?

I want to make the textbox allow only three digits and three decimals.For example 999.999.similarly it doesnt allow any characters like a,b,/,etc.How can I do with the Jquery? ...