File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -864,7 +864,11 @@ protected static function highlightToken($token)
864864 if (self ::is_cli ()) {
865865 $ token = $ token [self ::TOKEN_VALUE ];
866866 } else {
867- $ token = @htmlentities ($ token [self ::TOKEN_VALUE ],ENT_COMPAT ,'UTF-8 ' );
867+ if (defined ('ENT_IGNORE ' )) {
868+ $ token = htmlentities ($ token [self ::TOKEN_VALUE ],ENT_COMPAT | ENT_IGNORE ,'UTF-8 ' );
869+ } else {
870+ $ token = htmlentities ($ token [self ::TOKEN_VALUE ],ENT_COMPAT ,'UTF-8 ' );
871+ }
868872 }
869873
870874 if ($ type ===self ::TOKEN_TYPE_BOUNDARY ) {
Original file line number Diff line number Diff line change @@ -25,6 +25,21 @@ function testFormat($sql, $html) {
2525 function testHighlight ($ sql , $ html ) {
2626 $ this ->assertEquals (trim ($ html ), trim (SqlFormatter::highlight ($ sql )));
2727 }
28+
29+ function testHighlightBinary () {
30+ $ sql = 'SELECT " ' . pack ('H* ' , "ed180e98a47a45b3bdd304b798bc5797 " ) . '" AS BINARY ' ;
31+
32+ if (defined ('ENT_IGNORE ' )) {
33+ // this is what gets written as string
34+ $ binaryData = '" ' . pack ('H* ' , "180e7a450457 " ) . '" ' ;
35+ } else {
36+ $ binaryData = '' ;
37+ }
38+
39+ $ html = '<pre style="color: black; background-color: white;"><span style="font-weight:bold;">SELECT</span> <span style="color: blue;"> ' . $ binaryData . '</span> <span style="font-weight:bold;">AS</span> <span style="color: #333;">BINARY</span></pre> ' ;
40+
41+ $ this ->assertEquals (trim ($ html ), trim (SqlFormatter::highlight ($ sql )));
42+ }
2843 /**
2944 * @dataProvider highlightCliData
3045 */
You can’t perform that action at this time.
0 commit comments