Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#ccccFF
public static void main(String[] args) throws Exception {
  if (args.length < 1) {
    // handle error
  }
  String filename = args[0];

  Pattern pattern = Pattern.compile("[A^A-Za-z0-9%&+,.:=_]");
  Matcher matcher = pattern.matcher(filename);
  if (matcher.find()) {
    // filename contains bad chars, handle error
  }
  File f = new File(filename);
  OutputStream out = new FileOutputStream(f);
  // ...
}

...

CERT C Secure Coding Standard

MSC09-C. Character Encoding - Use Subset of ASCII for Safety

CERT C++ Secure Coding Standard

MSC09-CPP. Character Encoding - Use Subset of ASCII for Safety

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="03c387e865aa761d-d868e92c-477a41a2-b650a218-ba358f55063b0e183ed9a7c5"><ac:plain-text-body><![CDATA[

[ISO/IEC TR 24772:2010

http://www.aitcnet.org/isai/]

"Choice of Filenames and other External Identifiers [AJN]"

]]></ac:plain-text-body></ac:structured-macro>

MITRE CWE

CWE-116, "Improper Encoding or Escaping of Output"

...

ISO/IEC 646-1991

ISO 7-bit coded character set for information interchange

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="640a70fb6a1a4c1b-648f6d38-49124865-9175af6a-b7dfc1a2b6b6b3249b7aef78"><ac:plain-text-body><![CDATA[

[[Kuhn 2006

AA. Bibliography#Kuhn 06]]

UTF-8 and Unicode FAQ for UNIX/Linux

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="b497ecea0d092579-ed5e9019-4109456a-b9a68880-9528806c1d12a8f9c9faf8c0"><ac:plain-text-body><![CDATA[

[[Wheeler 2003

AA. Bibliography#Wheeler03]]

5.4 File Names]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="71142d824ed07765-81bddf79-4aef48c7-b5e5b9b3-bb5adb80d7b12e5402f90569"><ac:plain-text-body><![CDATA[

[[VU#881872

AA. Bibliography#VU881872]]

 

]]></ac:plain-text-body></ac:structured-macro>

...