I have been writing one c code to validate any url passed by a user.
Here is the code I have so far coded.
I am using one dictionary file to check values like http, https, www, ftp, etc for the URL that a user will pass for validation.
My code so far holds good for every thing except for if blank spaces or a new line character or a tab is mentioned in the URL string passed by user. I m getting a segmentation fault.
Please Help me.
Moderator's Comments:
Code tags for code, please.
Last edited by Corona688; 05-17-2012 at 12:23 PM..
Your complete and total lack of comments makes it difficult to even begin to figure out where your code is going wrong. You haven't posted what's in your dictionary file either, making it very difficult to guess your intent. breaking the string apart on "." won't get you the http:// at the beginning, either. I've corrected your indenting as best I can.
I think your code needs a rewrite. A lot of things which could've been done with loops or function calls you've done by simple brute force.
Your for-loop while reading the file probably doesn't do what you want. It will loop through every line, meaning, you only get the value you checked for the very last line -- every other value is overwritten by the one after.
Whenever you've decided a URL is invalid, you can just return(0) right then and there, instead of checking f_valid every time thereafter.
You do realize that strtok() modifies its input string, yes?
Also, it'd be better to check for allowable characters than disallowed ones:
I am learning Shell scripting on own. I am trying to do an assignment to get details from the user like username their individual marks ,DOB and send a report in mail with the Details calculated like total and average.
validate_marks() {
local Value=$1
if &&
then
return 0
else... (1 Reply)
Hello,
Am very new to perl , please help me here !!
I need help in reading a URL from command line using PERL:: Mechanize and needs all the contents from the URL to get into a file.
below is the script which i have written so far ,
#!/usr/bin/perl
use LWP::UserAgent;
use... (2 Replies)
Here is what I have so far:
find . -name "*php*" -or -name "*htm*" | xargs grep -i iframe | awk -F'"' '/<iframe*/{gsub(/.\*iframe>/,"\"");print $2}'
Here is an example content of a PHP or HTM(HTML) file:
<iframe src="http://ADDRESS_1/?click=5BBB08\" width=1 height=1... (18 Replies)
I am trying to find a way to test some code, but I need to rewrite a specific URL only from a specific HTTP_HOST
The call goes out to
http://SUB.DOMAIN.COM/showAssignment/7bde10b45efdd7a97629ef2fe01f7303/jsmodule/Nevow.Athena
The ID in the middle is always random due to the cookie.
I... (5 Replies)
Hi All,
I need to write a small piece of code to check the following.
name should contain (A-Z), spaces, hyphens & apostrophes
I need to generate regular expressions for the same.
Please help me out as i am not familiar with regular expressions. (1 Reply)
Hello,
I need to redirect an existing URL, how can i do that?
There's a current web address to a GUI that I have to redirect to another webaddress. Does anyone know how to do this?
This is on Unix boxes Linux.
example:
https://m45.testing.address.net/host.php
make it so the... (3 Replies)
I'm kinda new in shell scripting. How do i validate an input from a user to conform to requirement. For example,
echo "Enter First Name: "
read FName
echo "Enter Date of Employment (dd/mm/yyyy): "
read DoE
If the user enters data that is alphanumeric, it accepts it. I hope i've... (1 Reply)