mirror_edk2/BaseTools/Source/Python
Jordan Justen d80e451b18 BaseTools/UniClassObject: Verify valid UCS-2 chars in UTF-16 .uni files
Supplementary Plane characters can exist in UTF-16 files,
but they are not valid UCS-2 characters.

For example, refer to this python interpreter code:
>>> import codecs
>>> codecs.encode(u'\U00010300', 'utf-16')
'\xff\xfe\x00\xd8\x00\xdf'

Therefore the UCS-4 0x00010300 character is encoded as two
16-bit numbers (0xd800 0xdf00) in a little endian UTF-16
file.

For more information, see:
http://en.wikipedia.org/wiki/UTF-16#U.2B10000_to_U.2B10FFFF

This means that our current BaseTools code could be allowing
unsupported UTF-16 characters be used. To fix this, we decode the file
using python's utf-16 decode support. Then we verify that each
character's code point is 0xffff or less.

v3:
 * Based on Mike Kinney's feedback, we now read the whole file and
   verify up-front that it contains valid UCS-2 characters. Thanks
   also to Laszlo Ersek for pointing out the Supplementary Plane
   characters.

v4:
 * Reject code points in 0xd800-0xdfff range since they are reserved
   for UTF-16 surrogate pairs. (lersek)

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Yingke Liu <yingke.d.liu@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17694 6f19259b-4bc3-4df7-8a09-765794883524
2015-06-23 23:34:19 +00:00
..
AutoGen BaseTools/UniClassObject: Verify valid UCS-2 chars in UTF-16 .uni files 2015-06-23 23:34:19 +00:00
BPDG There is a limitation on WINDOWS OS for the length of entire file path can’t be larger than 255. There is an OS API provided by Microsoft to add “\\?\” before the path header to support the long file path. Enable this feature on basetools. 2014-08-15 03:06:48 +00:00
build BaseTools: Build report should not be generated if build failed. 2015-06-23 06:49:25 +00:00
Common BaseTools/EdkLogger: Support unit tests with a SILENT log level 2015-06-23 23:34:09 +00:00
CommonDataClass BaseTools: Supported FMP capsule image. 2015-06-23 06:46:01 +00:00
Ecc BaseTools/ECC: Fix some issues of ECC tool 2014-12-09 06:41:58 +00:00
Eot There is a limitation on WINDOWS OS for the length of entire file path can’t be larger than 255. There is an OS API provided by Microsoft to add “\\?\” before the path header to support the long file path. Enable this feature on basetools. 2014-08-15 03:06:48 +00:00
GenFds BaseTools: Supported FMP capsule image. 2015-06-23 06:46:01 +00:00
GenPatchPcdTable There is a limitation on WINDOWS OS for the length of entire file path can’t be larger than 255. There is an OS API provided by Microsoft to add “\\?\” before the path header to support the long file path. Enable this feature on basetools. 2014-08-15 03:06:48 +00:00
PatchPcdValue There is a limitation on WINDOWS OS for the length of entire file path can’t be larger than 255. There is an OS API provided by Microsoft to add “\\?\” before the path header to support the long file path. Enable this feature on basetools. 2014-08-15 03:06:48 +00:00
Rsa2048Sha256Sign Contributed-under: TianoCore Contribution Agreement 1.0 2014-08-14 20:08:17 +00:00
Table There is a limitation on WINDOWS OS for the length of entire file path can’t be larger than 255. There is an OS API provided by Microsoft to add “\\?\” before the path header to support the long file path. Enable this feature on basetools. 2014-08-15 03:06:48 +00:00
TargetTool License header updated to match correct format. 2014-08-28 13:53:34 +00:00
Trim License header updated to match correct format. 2014-08-28 13:53:34 +00:00
UPT BaseTools/Upt: Update help message 2015-06-19 00:05:25 +00:00
Workspace BaseTools/Build: Add error report for incorrect syntax in DEC file. 2015-06-23 08:45:06 +00:00
GNUmakefile Sync BaseTool trunk (version r2599) into EDKII BaseTools. 2013-08-23 02:18:16 +00:00
Makefile Adds new files to the Makefile for testing changed sources 2015-06-10 14:34:40 +00:00
sitecustomize.py License header updated to match correct format. 2014-08-28 13:53:34 +00:00