Uploaded image for project: 'Sling'
  1. Sling
  2. SLING-4522

Sling Mocks: Contentloader fails for UTF8 encoded json files on Windows Systems

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • Testing Sling Mock 1.2.0
    • Testing Sling Mock 1.3.0
    • Testing
    • None

    Description

      The Sling Mock package allows developers to load content from a json file using the ContentLoader.

      ContentLoader.json(JSON_PATH, TARGET)
      

      The actual loading is performed in ContentLoader.java:327 using

      IOUtils.toString(inputStream);
      

      As soon as you try to load a UTF-8 encoded JSON (as per default) on a windows platform, this fails due to encoding issues:

      "jcr:title": "English Ö",
      

      is loaded as

      English [Ö]
      

      As json is per definition UTF-8 encoded, I would suggest to set the encoding explicit by changing the line above to

      return IOUtils.toString(inputStream, "UTF-8");
      

      Attachments

        1. SLING-4522.diff
          2 kB
          Alexander Muthmann

        Activity

          People

            sseifert Stefan Seifert
            amuthmann Alexander Muthmann
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: