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):
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.