Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: in the 2nd CS, the pattern string was badly modified (on revision 39). reverted to the original pattern string.

...

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="2f867437cc502a92-153e1072-4c3f4102-968a9654-873bb5ff902d90ff8519d918"><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="1871a023367a1ddf-c3cb3b68-4f0d4586-baea9343-3cf420821fefb2088f260290"><ac:plain-text-body><![CDATA[

[[Kuhn 2006

AA. References#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="1d5ac9417f3c834a-8785a5fd-490f417f-827eb4bf-02b5b2f9429946f25f439a7c"><ac:plain-text-body><![CDATA[

[[Wheeler 2003

AA. References#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="bf27c8f5f8641435-3e6e6522-4e2f4965-b2438f25-838be6d935c470f5864d356b"><ac:plain-text-body><![CDATA[

[[VU#439395

AA. References#VU439395]]

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

...