Create a "safe" file name given the BeanId. There are a number of
characters which can cause problems on different platforms. A safe
file name will container only the following characters
a-z, A-Z, _, -, .
All other characters will get converted to a _
174150
private String getPortableFilename(BeanId beanId)
    {
        // Historically, this method returned the equivalent of
        // appendPortableFilenameString(beanId.toString()), where BeanId.toString
        // returned "BeanId(" + j2eeName + ", " + pkey + ")", which translates to
        // "BeanId_" + j2eeName + "__" + pkey + "_".                     RTC102568

        StringBuilder result = new StringBuilder();
        result.append(FILENAME_PREFIX);
        appendPortableFilenameString(result, beanId.getJ2EEName().toString());
        result.append("__");
        appendPortableFilenameString(result, beanId.getPrimaryKey().toString());
        result.append('_');
        return result.toString();
    }
50614
def gen_filename(endpoint):
    
    now = datetime.now().strftime('%Y%m%d_%H%M%S%f')[:-4]
    base = endpoint.split('://', 1)[1]
    if base.startswith('localhost:'):
        base = gethostname().split('.')[0] + base[9:]
    base = base.replace(':', '_').replace('/', '_')
    return '{}_{}.h5'.format(base, now)
534228
@Override
	public String name() {

		if (file == null) {
			return null;
		}

		String name = null;

		try (Tx tx = StructrApp.getInstance(securityContext).tx()) {

			name = file.getName();
			tx.success();

		} catch (FrameworkException fex) {
			logger.error("", fex);
		}

		return name;
	}
913916
@InterfaceAudience.Private
    private String pathForDatabaseNamed(String name) {
        if ((name == null) || (name.length() == 0) || Pattern.matches(LEGAL_CHARACTERS, name))
            return null;
        // NOTE: CouchDB allows forward slash as part of database name.
        //       However, ':' is illegal character on Windows platform.
        //       For Windows, substitute with period '.'
        name = isWindows() ? name.replace('/', '.') : name.replace('/', ':');
        String result = directoryFile.getPath() + File.separator + name + Manager.kDBExtension;
        return result;
    }
646749
def __safe_name(self, method_name):
    """"""
    # Endpoints backend restricts what chars are allowed in a method name.
    safe_name = re.sub(r'[^\.a-zA-Z0-9_]', '', method_name)

    # Strip any number of leading underscores.
    safe_name = safe_name.lstrip('_')

    # Ensure the first character is lowercase.
    # Slice from 0:1 rather than indexing [0] in case safe_name is length 0.
    return safe_name[0:1].lower() + safe_name[1:]
716844
private String osFriendly(String data) {
        /* Allow only permissable characters to be used in filenames */

        String dataCopy = "";
        char c;
        boolean valid;

        for (int i = 0; i < data.length(); i++) {
            c = data.charAt(i);

            valid = true;
            if ((c > 0x00) && (c < 0x20)) {
                valid = false;
            }
            if ((c > 0x7E) && (c < 0xA0)) {
                valid = false;
            }

            switch (c) {
                case '/':
                case '\\':
                case '?':
                case '%':
                case '*':
                case ':':
                case '|':
                case '"':
                case '<':
                case '>':
                case '.':
                case ',':
                case '=':
                case '+':
                case ']':
                case '[':
                case '!':
                case '@':
                    valid = false;
            }

            if (valid) {
                dataCopy += c;
            }

        }

        return dataCopy;
    }
874270
private String getFileName(String fileName) {

        if (fileName != null) {
            int index = fileName.indexOf(':');
            if (index < 0) {
                return fileName;
            } else {

                fileName = fileName.substring(index + 1);

                index = fileName.lastIndexOf('/');
                if (index < 0) {
                    return fileName;
                } else {
                    return fileName.substring(index + 1);
                }

            }
        }
        return null;
    }
218768
static void validateHeaderName(CharSequence name) {
        if (name == null) {
            throw new NullPointerException("name");
        }
        if (name.length() == 0) {
            throw new IllegalArgumentException(
                    "name cannot be length zero");
        }
        // Since name may only contain ascii characters, for valid names
        // name.length() returns the number of bytes when UTF-8 encoded.
        if (name.length() > SPDY_MAX_NV_LENGTH) {
            throw new IllegalArgumentException(
                    "name exceeds allowable length: " + name);
        }
        for (int i = 0; i < name.length(); i ++) {
            char c = name.charAt(i);
            if (c == 0) {
                throw new IllegalArgumentException(
                        "name contains null character: " + name);
            }
            if (c >= 'A' && c <= 'Z') {
                throw new IllegalArgumentException("name must be all lower case.");
            }
            if (c > 127) {
                throw new IllegalArgumentException(
                        "name contains non-ascii character: " + name);
            }
        }
    }
1053058
def cf_safe_name(name):
    
    alphanumeric = r"[a-zA-Z0-9]+"
    parts = re.findall(alphanumeric, name)
    return "".join([uppercase_first_letter(part) for part in parts])
1239110
private String generateFileName() {
        int checksum = 1;

        Set<TypeId<?>> typesKeySet = types.keySet();
        Iterator<TypeId<?>> it = typesKeySet.iterator();
        int[] checksums = new int[typesKeySet.size()];
        int i = 0;

        while (it.hasNext()) {
            TypeId<?> typeId = it.next();
            TypeDeclaration decl = getTypeDeclaration(typeId);
            Set<MethodId> methodSet = decl.methods.keySet();
            if (decl.supertype != null) {
                int sum = 31 * decl.supertype.hashCode() + decl.interfaces.hashCode();
                checksums[i++] = 31 * sum + methodSet.hashCode();
            }
        }
        Arrays.sort(checksums);

        for (int sum : checksums) {
            checksum *= 31;
            checksum += sum;
        }

        return "Generated_" + checksum +".jar";
    }
972410
public static String sanitizeName(String name) {

        if (name  == null)
            throw new NullPointerException("Parameter name cannot be null");

        name = name.trim();

        if (name.length() == 0)
            throw new IllegalArgumentException("Parameter name cannot be empty");

        StringBuilder ret = new StringBuilder("");

        for (int i = 0; i < name.length(); i++) {
            char ch = name.charAt(i);
            if (Character.isLetter(ch) || Character.isDigit(ch)) {
                ret.append(ch);
            } else {
                ret.append("_");
            }

        }

        return ret.toString();
    }
94612
function normalizeFileName (name, extension, format) {
  if (name.startsWith('@')) {
    name = name.slice(name.lastIndexOf('/') + 1)
  }
  if (format === 'umd' || !format) {
    return `${name}.${extension}`
  }
  return `${name}.${format}.${extension}`
}
1366697
public String buildFilename(final ProblemInput input, final int attempt) {
		final StringBuilder builder = new StringBuilder();
		final Problem problem = input.getProblem();
		final ContestInfo info = problem.getParent();
		final int index = info.getProblems().indexOf(problem);
		final char letter = (char) ((int) 'A' + index);
		builder.append(letter)
			.append(FILENAME_SEPARATOR)
			.append(input.getName())
			.append(FILENAME_SEPARATOR);
		if (attempt == -1) {
			builder.append(PRACTICE);
		}
		else {
			builder.append(attempt);
		}
		builder.append(INPUT_EXTENSION);
		return builder.toString();
	}
704538
public function sanitize_filename($name, $max_length = 50) {
		$special_chars = ['#','$','%','^','&','*','!','~','‘','"','’','\'','=','?','/','[',']','(',')','|','<','>',';','\\',',','+'];
		$name = preg_replace('/^[.]*/','',$name); // remove leading dots
		$name = preg_replace('/[.]*$/','',$name); // remove trailing dots
		$name = str_replace($special_chars, '', $name);// remove special characters
		$name = str_replace(' ','_',$name); // replace spaces with _

		$name_array = explode('.', $name);

		if (count($name_array) > 1) {
			$extension = array_pop($name_array);
		} else {
			$extension = null;
		}

		$name = implode('.', $name_array);
		if ($max_length != null) {
			$name = substr($name, 0, $max_length);
		}

		if ($extension != null) {
			$name = $name . '.' . $extension;
		}

		return $name;
	}
188252
@Override
    public String getFileName(Tuple<String, Element> data) {
        return SafeFilenameUtils.makeSafeFilename(data.first);
    }
431343
def sanitize_name(name, prefer = nil)
      path = name.to_s

      # Check if we haven't got an extension
      # we'll assume you're looking for prefer or "html" otherwise
      path += ".#{prefer || 'html'}" unless File.basename(path).include?(".")

      path
    end
401061
private String encodeFileName(String fileName) {

		String result = Normalizer.normalize(fileName, Normalizer.Form.NFD).replaceAll("\\s+", "-")
				.replaceAll("[^A-Za-z0-9_\\-\\.]", "");
		if (result.isEmpty()) {
			result = "report";
		}
		return result;
	}