Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "xfa/fde/xml/fde_xml_imp.h" | 7 #include "xfa/fde/xml/fde_xml_imp.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 1839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1850 if (m_iEntityStart > -1 && ch == L';') { | 1850 if (m_iEntityStart > -1 && ch == L';') { |
| 1851 CFX_WideString csEntity; | 1851 CFX_WideString csEntity; |
| 1852 m_BlockBuffer.GetTextData(csEntity, m_iEntityStart + 1, | 1852 m_BlockBuffer.GetTextData(csEntity, m_iEntityStart + 1, |
| 1853 (m_iDataLength - 1) - m_iEntityStart - 1); | 1853 (m_iDataLength - 1) - m_iEntityStart - 1); |
| 1854 int32_t iLen = csEntity.GetLength(); | 1854 int32_t iLen = csEntity.GetLength(); |
| 1855 if (iLen > 0) { | 1855 if (iLen > 0) { |
| 1856 if (csEntity[0] == L'#') { | 1856 if (csEntity[0] == L'#') { |
| 1857 ch = 0; | 1857 ch = 0; |
| 1858 FX_WCHAR w; | 1858 FX_WCHAR w; |
| 1859 if (iLen > 1 && csEntity[1] == L'x') { | 1859 if (iLen > 1 && csEntity[1] == L'x') { |
| 1860 for (int32_t i = 2; i < iLen; i++) { | 1860 int32_t i = 2; |
| 1861 w = csEntity[i]; | 1861 while (i < iLen && csEntity[i] == '0') |
| 1862 if (w >= L'0' && w <= L'9') { | 1862 i++; |
| 1863 ch = (ch << 4) + w - L'0'; | 1863 if (iLen - i <= 4) { |
| 1864 } else if (w >= L'A' && w <= L'F') { | 1864 for (; i < iLen; i++) { |
| 1865 ch = (ch << 4) + w - 55; | 1865 w = csEntity[i]; |
| 1866 } else if (w >= L'a' && w <= L'f') { | 1866 if (w >= L'0' && w <= L'9') { |
| 1867 ch = (ch << 4) + w - 87; | 1867 ch = (ch << 4) + w - L'0'; |
| 1868 } else { | 1868 } else if (w >= L'A' && w <= L'F') { |
| 1869 break; | 1869 ch = (ch << 4) + w - 55; |
| 1870 } else if (w >= L'a' && w <= L'f') { | |
| 1871 ch = (ch << 4) + w - 87; | |
| 1872 } else { | |
| 1873 break; | |
| 1874 } | |
| 1870 } | 1875 } |
| 1876 } else { | |
| 1877 ch = ' '; | |
| 1871 } | 1878 } |
| 1872 } else { | 1879 } else { |
| 1873 for (int32_t i = 1; i < iLen; i++) { | 1880 for (int32_t i = 1; i < iLen; i++) { |
| 1874 w = csEntity[i]; | 1881 w = csEntity[i]; |
| 1875 if (w < L'0' || w > L'9') { | 1882 if (w < L'0' || w > L'9') |
| 1883 break; | |
| 1884 ch = ch * 10 + w - L'0'; | |
| 1885 | |
| 1886 if (ch < 0) { | |
|
Wei Li
2016/08/10 17:28:30
Could you also use length based checking here? If
dsinclair
2016/08/10 17:31:04
I don't think so. This check doesn't do the shifts
Wei Li
2016/08/10 20:18:48
Sorry for the back and forth. I am trying to find
dsinclair
2016/08/10 20:58:08
No need to apologize, code working same on all pla
| |
| 1887 ch = ' '; | |
| 1876 break; | 1888 break; |
| 1877 } | 1889 } |
| 1878 ch = ch * 10 + w - L'0'; | |
| 1879 } | 1890 } |
| 1880 } | 1891 } |
| 1881 if (ch != 0) { | 1892 if (ch != 0) { |
| 1882 m_BlockBuffer.SetTextChar(m_iEntityStart, ch); | 1893 m_BlockBuffer.SetTextChar(m_iEntityStart, ch); |
| 1883 m_iEntityStart++; | 1894 m_iEntityStart++; |
| 1884 } | 1895 } |
| 1885 } else { | 1896 } else { |
| 1886 if (csEntity.Compare(L"amp") == 0) { | 1897 if (csEntity.Compare(L"amp") == 0) { |
| 1887 m_BlockBuffer.SetTextChar(m_iEntityStart, L'&'); | 1898 m_BlockBuffer.SetTextChar(m_iEntityStart, L'&'); |
| 1888 m_iEntityStart++; | 1899 m_iEntityStart++; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 1904 m_BlockBuffer.DeleteTextChars(m_iDataLength - m_iEntityStart, FALSE); | 1915 m_BlockBuffer.DeleteTextChars(m_iDataLength - m_iEntityStart, FALSE); |
| 1905 m_pCurrentBlock = m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); | 1916 m_pCurrentBlock = m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); |
| 1906 m_iEntityStart = -1; | 1917 m_iEntityStart = -1; |
| 1907 } else { | 1918 } else { |
| 1908 if (m_iEntityStart < 0 && ch == L'&') { | 1919 if (m_iEntityStart < 0 && ch == L'&') { |
| 1909 m_iEntityStart = m_iDataLength - 1; | 1920 m_iEntityStart = m_iDataLength - 1; |
| 1910 } | 1921 } |
| 1911 } | 1922 } |
| 1912 m_pStart++; | 1923 m_pStart++; |
| 1913 } | 1924 } |
| OLD | NEW |