Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | [Bug 2809525] Abort on overlong color name |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
550636bb493213960f40920b25006e5f |
User & Date: | jan.nijtmans 2012-03-21 22:23:32 |
Context
2012-03-26
| ||
12:35 | fix for scoping of buf (introduced with fix for [Bug 2809525]) check-in: e8d270f5 user: jan.nijtmans tags: trunk | |
12:21 | implement for Unix as well check-in: 4e406d9e user: jan.nijtmans tags: jn-web-colors | |
2012-03-21
| ||
22:23 | [Bug 2809525] Abort on overlong color name check-in: 550636bb user: jan.nijtmans tags: trunk | |
22:22 | [Bug 2809525] Abort on overlong color name check-in: 89ebf1b8 user: jan.nijtmans tags: core-8-5-branch | |
2012-03-18
| ||
21:03 | rfe-3503317: XParseColor speedup check-in: fb808d0d user: jan.nijtmans tags: trunk | |
Changes
Changes to ChangeLog.
1 2 3 4 5 6 7 | 2012-03-18 Jan Nijtmans <[email protected]> * xlib/xcolors.c: [RFE 3503317]: XParseColor speedup * xlib/rgb.txt: List of all colors accepted by Tk in Xorg format * tests/color.test: Added test case for all colors in rgb.txt 2012-03-13 Donal K. Fellows <[email protected]> | > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 | 2012-03-21 Jan Nijtmans <[email protected]> * generic/tkColor.c: [Bug 2809525] Abort on overlong color name. * unix/tkUnixColor.c: 2012-03-18 Jan Nijtmans <[email protected]> * xlib/xcolors.c: [RFE 3503317]: XParseColor speedup * xlib/rgb.txt: List of all colors accepted by Tk in Xorg format * tests/color.test: Added test case for all colors in rgb.txt 2012-03-13 Donal K. Fellows <[email protected]> |
︙ | ︙ |
Changes to generic/tkColor.c.
︙ | ︙ | |||
826 827 828 829 830 831 832 | } #ifndef __WIN32__ /* This function is not necessary for Win32, * since XParseColor already does the right thing */ Status TkParseColor( | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > | > > > > | > | | 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 | } #ifndef __WIN32__ /* This function is not necessary for Win32, * since XParseColor already does the right thing */ Status TkParseColor( Display *display, /* The display */ Colormap map, /* Color map */ const char *name, /* String to be parsed */ XColor *color) { if (*name == '#') { char buf[14]; buf[0] = '#'; buf[13] = '\0'; if (!*(++name) || !*(++name) || !*(++name)) { /* Not at least 3 hex digits, so invalid */ return 0; } else if (!*(++name)) { /* Exactly 3 hex digits */ buf[9] = buf[10] = buf[11] = buf[12] = *(--name); buf[5] = buf[6] = buf[7] = buf[8] = *(--name); buf[1] = buf[2] = buf[3] = buf[4] = *(--name); name = buf; } else if (!*(++name) || !*(++name)) { /* Not at least 6 hex digits, so invalid */ return 0; } else if (!*(++name)) { /* Exactly 6 hex digits */ buf[10] = buf[12] = *(--name); buf[9] = buf[11] = *(--name); buf[6] = buf[8] = *(--name); buf[5] = buf[7] = *(--name); buf[2] = buf[4] = *(--name); buf[1] = buf[3] = *(--name); name = buf; } else if (!*(++name) || !*(++name)) { /* Not at least 9 hex digits, so invalid */ return 0; } else if (!*(++name)) { /* Exactly 9 hex digits */ buf[11] = *(--name); buf[10] = *(--name); buf[9] = buf[12] = *(--name); buf[7] = *(--name); buf[6] = *(--name); buf[5] = buf[8] = *(--name); buf[3] = *(--name); buf[2] = *(--name); buf[1] = buf[4] = *(--name); name = buf; } else if (!*(++name) || !*(++name) || *(++name)) { /* Not exactly 12 hex digits, so invalid */ return 0; } else { name -= 13; } } else { if (strlen(name) > 99) { /* Don't bother to parse this. [Bug 2809525]*/ return 0; } } return XParseColor(display, map, name, color); } #endif /* __WIN32__ */ /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 |
︙ | ︙ |
Changes to unix/tkUnixColor.c.
︙ | ︙ | |||
122 123 124 125 126 127 128 | Tk_Uid name) /* Name of color to allocated (in form * suitable for passing to XParseColor). */ { Display *display = Tk_Display(tkwin); Colormap colormap = Tk_Colormap(tkwin); XColor color; TkColor *tkColPtr; | < < < < < < < < < < < < < < > > > | | | | 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | Tk_Uid name) /* Name of color to allocated (in form * suitable for passing to XParseColor). */ { Display *display = Tk_Display(tkwin); Colormap colormap = Tk_Colormap(tkwin); XColor color; TkColor *tkColPtr; /* * Map from the name to a pixel value. Call XAllocNamedColor rather than * XParseColor for non-# names: this saves a server round-trip for those * names. */ if (*name != '#') { XColor screen; if (strlen(name) > 99) { /* Don't bother to parse this. [Bug 2809525]*/ return (TkColor *) NULL; } else if (XAllocNamedColor(display, colormap, name, &screen, &color) != 0) { DeleteStressedCmap(display, colormap); } else { /* * Couldn't allocate the color. Try translating the name to a * color value, to see whether the problem is a bad color name or * a full colormap. If the colormap is full, then pick an * approximation to the desired color. */ if (XLookupColor(display, colormap, name, &color, &screen) == 0) { return NULL; } FindClosestColor(tkwin, &screen, &color); } } else { if (TkParseColor(display, colormap, name, &color) == 0) { return NULL; } if (XAllocColor(display, colormap, &color) != 0) { DeleteStressedCmap(display, colormap); } else { FindClosestColor(tkwin, &color, &color); } |
︙ | ︙ |