esthervidal78 / json-smart

Automatically exported from code.google.com/p/json-smart
0 stars 0 forks source link

Style escape/protect is broken (incorrect bit logic) #24

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
The following code exists in both v1 and v2 of JSONStyle.java:

    _protectKeys = (FLAG & FLAG_PROTECT_KEYS) == 0;
    _protectValues = (FLAG & FLAG_PROTECT_VALUES) == 0;
    _protect4Web = (FLAG & FLAG_PROTECT_4WEB) == 0;

Presumably this is meant to check that FLAG is set, and that (e.g.) it contains 
the FLAG_PROTECT_4WEB flag.  Except that by comparing to zero, you're doing the 
opposite of what you want.  You should be comparing to "> 0" not "== 0" (like 
you do a few lines below that with the FLAG_AGRESSIVE check).

Anyway, this has the unfortunate effect of making it impossible to use any of 
the "protect" features.

Attached diff should fix the issue for v1.

Original issue reported on code.google.com by ibex...@gmail.com on 22 Mar 2012 at 10:56

Attachments:

GoogleCodeExporter commented 8 years ago
this is a semantic issue in this part of the code. I may fix that by renaming 
FLAG_* by MASK_*.

Original comment by uriel.chemouni on 3 Apr 2012 at 8:55

GoogleCodeExporter commented 8 years ago
Please Read the new TestCompressorFlags.java in V 1.1.1 or 2.0-RC2

this file contains sample of JsonStyle special usage

Original comment by uriel.chemouni on 3 Apr 2012 at 10:03

GoogleCodeExporter commented 8 years ago

Original comment by uriel.chemouni on 6 Jun 2014 at 6:22