Uploaded image for project: 'Blazegraph (by SYSTAP)'
  1. Blazegraph (by SYSTAP)
  2. BLZG-5736

Strings with quotes are not properly encoded in federated queries

    XMLWordPrintable

    Details

      Description

      When using federated query via SERVICE, strings with quotes are not properly encoded, resulting in invalid SPARQL being sent out. For example, this is one of the queries produced (with prefixes removed):

      SELECT  ?o
      WHERE {
      
        <http://www.wikidata.org> <http://schema.org/dateModified> ?o .
        
      }
      VALUES ( ?o) {
      ( "sto fatto o sta cosa ? no tipo 'e nato elemento"@nap )
      ( "dette elementet er et konkret objekt/eksemplar (instans) av denne klassen, kategorien eller objektgruppen"@nb )
      ( "dit item is n eksemplaor/instansie van t tweede item (Veurbeeld: "Mark Rutte" is nen "politieker")"@nds-nl )
      ( "???? ??? ??????? ?? ?????? ?????? ? ???? ??? ?????? ????? ????? ??????"@ne )
      ( "dit item is een exemplaar (instantie) van deze groep elementen"@nl )
      ( "natura de, expression de o exemplar de"@oc )
      ( "stanowi przyk?ad (jest elementem) danej kategorii/klasy"@pl )
      ( "este item ? uma inst?ncia deste outro item"@pt )
      ( "este item ? uma inst?ncia deste outro item"@pt-br )
      ( "????"@rif )
      ( "acest element este un exemplar din clasa definit? de acel element"@ro )
      ( "?????? ??????? ???????????? ????? ?????????? ?????? (????????? / ??????? ??????) ??????, ????????? ??? ?????? ????????"@ru )
      ( "sta cosa ? n'esimplari cuncretu di sta classi, di sta catigur?a, o di stu cuncettu"@scn )
      ( "je konkretna izvedba objekta v razredu, kategoriji ali skupini objektov"@sl )
      ( "??? ?????? ?? ????????? ??????? (????????) ?????, ?????????? ??? ????? ????????"@sr )
      ( "??? ?????? ?? ????????? ??????? (????????) ?????, ?????????? ??? ????? ????????"@sr-ec )
      ( "ova stavka je konkretan objekat (instanca) klase, kategorije ili grupe objekata"@sr-el )
      ( "?r ett konkret objekt (instans) av denna klass, kategori eller objektgrupp"@sv )
      ( "??? ??????? ? ?????????? ????????? ??'???? (??????? ???????) ?????? ?????, ????????? ?? ????? ??'?????"@uk )
      ( "kho?n m?c n?y l? m?t th?c th? c?a kho?n m?c kia"@vi )
      }
      

      Note the third value - quotes there should be escaped, but they are not.

      Looks like the bug is in AST2SPARQLUtil.toExternal(Literal) - it does not do any encoding for the literal. This can be fixed by either using the three-quotes syntax (https://www.w3.org/TR/sparql11-query/#QSynLiterals) - still needs to check for three quotes in text though - or escaping quotes and probably other characters not acceptable in SPARQL strings. According to https://www.w3.org/TR/sparql11-query/#rSTRING_LITERAL2, #x22#x5C#xA#xD should be escaped.

        Attachments

          Activity

            People

            Assignee:
            beebs Brad Bebee
            Reporter:
            stasmalyshev stasmalyshev
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: