Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1004753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:11:03+00:00 2026-05-16T08:11:03+00:00

The url would be something like this: www.example.com/index.php?file=myFile.ext The filtering would only allow leters

  • 0

The url would be something like this:

www.example.com/index.php?file=myFile.ext

The filtering would only allow leters and numbers in the file, and only one dot.

The filtering would not give characters from the input to the file functions, instead, on for every allowed character it matches in an internal array, it copies the character from the internal array, and not the character from the input.

Ex:

if( isset(MyArray[inputChar]))
    $fileName .= MyArray[inputChar]

This is especially to protect against weird encoding bugs, php bugs etc

The full example bellow (I used array_search() instead of isset()):

//split it to array of chars
 $imputCharacters = str_split($_GET["file"]);

 //splits it to array like this: [0] => 'a', [1] => 'b', etc 
 $allowedCharacters = str_split('1234567890abcdefghijklmnopqrstuvwxyz.ABCDEFGHIJKLMNOPQRSTUVWXYZ');

 $file = '';
 $dots = 0;

  foreach ($imputCharacters as $char) 
 {
   $indexKey = array_search($char, $allowedCharacters, true);
   if($indexKey === false) 
  {
   die(__FILE__ . __LINE__); // disalowed character
  }
  else 
  {
   if ($allowedCharacters[$indexKey] === '.') { 
    $dots++;
    if($dots > 1) {
     die(__FILE__ . __LINE__); //only one dot allowed
    }
   }
   $file .= $allowedCharacters[$indexKey];
  }   
  }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T08:11:04+00:00Added an answer on May 16, 2026 at 8:11 am

    Some other things you might want to watch out for:
    Opening hidden files. You might not want to open your .svn or .hg files (Source control files).
    URLs are case insensitive but they’re case sensitive on the file system, so somehow accomodate for that?
    Certain file names might having special meaning to the operating system? Such as the user providing a string that can be automatically decoded into something else on the filesystem?
    Are you looking our for character encoding bugs? The user might supply the text in a specific encoding, which could be interpreted differently by the operating systems character encoding scheme.
    Does the file exist?
    Does it have some weird flag on it (Read-Only, Write-Only)?
    Is the file readable by the web server’s user account? I’ve run into issues with UNIX based systems where files are not readable by the www_root account that apache runs as.
    I don’t know how many of these are likely, just some things I’ve run across trying to solve similar problems.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, I have a file like this: Url/Host: www.example.com Login: user Password: password Data_I_Dont_Need:
The url of our search page is build like this: http://www.example.com/results/name/John/city/Miami/gender/Male This would display
Currently, I have URLs that look like this: http://www.example.com/user/create http://www.example.com/user/edit/1 But now, I have
I have a special url which I would want only few people to have
I would like to intercept any URL which the user enters in their browser
I would like to restrict access to my /admin URL to internal IP addresses
I would like to serve a different content from a single URL depending on
How do I rewrite a URL in ASP.NET? I would like users to be
I need a user to be able to enter a URL, and would like
I am trying to create a route with a Username... So the URL would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.