Ignore:
Timestamp:
2019-03-26T01:58:41+01:00 (5 years ago)
Author:
Don-vip
Message:

fix #15645, fix #17521 - Detect and fix non-printing control characters

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/TagCheckerTest.java

    r14897 r14933  
    248248    }
    249249
     250    /**
     251     * Unit test of {@link TagChecker#removeNonPrintingControlCharacters}
     252     */
     253    @Test
     254    public void testRemoveUnprintableControlCharacters() {
     255        // Check 65 ASCII control characters are removed, except new lines
     256        for (char c = 0x0; c < 0x20; c++) {
     257            if (c != '\r' && c != '\n') {
     258                assertTrue(TagChecker.removeNonPrintingControlCharacters(Character.toString(c)).isEmpty());
     259            } else {
     260                assertFalse(TagChecker.removeNonPrintingControlCharacters(Character.toString(c)).isEmpty());
     261            }
     262        }
     263        assertTrue(TagChecker.removeNonPrintingControlCharacters(Character.toString((char) 0x7F)).isEmpty());
     264        // Check 9 Unicode bidi control characters are removed
     265        for (char c = 0x200c; c <= 0x200f; c++) {
     266            assertTrue(TagChecker.removeNonPrintingControlCharacters(Character.toString(c)).isEmpty());
     267        }
     268        for (char c = 0x202a; c <= 0x202e; c++) {
     269            assertTrue(TagChecker.removeNonPrintingControlCharacters(Character.toString(c)).isEmpty());
     270        }
     271    }
    250272}
Note: See TracChangeset for help on using the changeset viewer.