Sanitizing strings to make them URL and filename safe?

I found this larger function in the Chyrp code: /** * Function: sanitize * Returns a sanitized string, typically for URLs. * * Parameters: * $string – The string to sanitize. * $force_lowercase – Force the string to lowercase? * $anal – If set to *true*, will remove all non-alphanumeric characters. */ function sanitize($string, $force_lowercase … Read more

Is it possible to use “/” in a filename?

The answer is that you can’t, unless your filesystem has a bug. Here’s why: There is a system call for renaming your file defined in fs/namei.c called renameat: SYSCALL_DEFINE4(renameat, int, olddfd, const char __user *, oldname, int, newdfd, const char __user *, newname) When the system call gets invoked, it does a path lookup (do_path_lookup) … Read more

Get file name from URL

Instead of reinventing the wheel, how about using Apache commons-io: import org.apache.commons.io.FilenameUtils; public class FilenameUtilTest { public static void main(String[] args) throws Exception { URL url = new URL(“http://www.example.com/some/path/to/a/file.xml?foo=bar#test”); System.out.println(FilenameUtils.getBaseName(url.getPath())); // -> file System.out.println(FilenameUtils.getExtension(url.getPath())); // -> xml System.out.println(FilenameUtils.getName(url.getPath())); // -> file.xml } }

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)