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("[IDS05-J. Use a subset of ASCII for file and path names^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="0a8d2bc5aab6b79f-b0890880-489f4375-b327ab47-f2941a5ccbabe88c054ab7e0"><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="308f29c13e25ffe4-182ce047-4f0f40c0-ae10b39c-b449f74efc08afce78d0cf53"><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="ffc0430170d08b9c-2f79a7c8-410c47bc-967586ca-a962e7eb781eaa012d664452"><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="1a03be9f98cbaf48-8377c1bf-49054fef-9c96835d-172cc083953de3e7ee693a69"><ac:plain-text-body><![CDATA[

[[VU#881872

AA. Bibliography#VU881872]]

 

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

...