Uploaded image for project: 'Apache Jena'
  1. Apache Jena
  2. JENA-1393

FmtUtils.stringForURI does not compact URIs with ":" in localname

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Done
    • Affects Version/s: Jena 3.1.1, Jena 3.2.0, Jena 3.3.0, Jena 3.4.0
    • Fix Version/s: Jena 3.5.0
    • Component/s: ARQ, Jena
    • Labels:
      None

      Description

      Issue: FmtUtils.stringForURI does not compact URI with ":" in localname as the compacted
      prefixed form gets rejected by FmtUtils.validPNameChar(ch) function. However,
      according to the SPARQL specification ";" is allowed in prefixed form, see:
      https://www.w3.org/TR/sparql11-query/#rPN_LOCAL

      Note it ":" was not allowed in localname in older versions of the document (before 2013):
      https://www.w3.org/TR/2012/WD-sparql11-query-20120105/#rPN_LOCAL

      Proposed Fix: add the following line to FmtUtils.validPNameChar(ch):

               if ( ch == ':' )    return true ;
      

      Proposed Test add to TestFmtUtils:

          @Test
          public void stringForURI_colonInLocalname_shouldCompact() {
              String uri = aUri + "local:name";
              final String result = FmtUtils.stringForURI(uri, getPrefixMapping());
              assertEquals("zz:local:name", result);
          }
      

        Attachments

        1. fix_stringForURI.patch
          1 kB
          Michał Woźniak

          Issue Links

            Activity

              People

              • Assignee:
                andy Andy Seaborne
                Reporter:
                misias Michał Woźniak
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: