TurtleWriter does not renders string literals beginning with "\n" as multi-line literals

Description

TurtleWriter wrongly encodes string literals beginning with "\n"

The bug is located on the begging of the method:
org.openrdf.rio.turtle.TurtleWriter.writeLiteral(Literal)

if (label.indexOf('\n') > 0 || label.indexOf('\r') > 0 || label.indexOf('\t') > 0) {

should be

if (label.indexOf('\n') != 1 || label.indexOf('\r') != 1 || label.indexOf('\t') != 1) {

see the UnitTest attached

Environment

None

Activity

Show:
Jan Dědek
August 1, 2013, 5:02 AM
Edited

I corrected the attached TurtleWriterTest.java...

Dale W. Visser
August 1, 2013, 2:22 PM

Assigning to Peter since he has done most of the work lately on writers and parsers, and so is probably most familiar with the code there.

Peter Ansell
August 4, 2013, 11:19 PM

The literal that is printed is still correct, although it should be consistent with the other output if pretty printing is enabled, as it is by default.

I first tried to add the literal to the round-trip tests and nothing broke, before I realised this issue was just about the multi-line literal rendering.

Peter Ansell
August 4, 2013, 11:37 PM
Peter Ansell
August 5, 2013, 4:04 AM

Pull Request merged

Fixed

Assignee

Peter Ansell

Reporter

Jan Dědek

Labels

None

Time tracking

0m

Time remaining

1h

Components

Fix versions

Affects versions

Priority

Minor
Configure