Skip to content
Permalink
Browse files

[BUGFIX] 13118 QGIS Server - WFS - GeoJSON and escaping line breaks

Line breaks are not properly handled in GeoJSON results when making GetFeature requests.
Line breaks should be replaced by \\n.
  • Loading branch information
rldhont committed Nov 11, 2015
1 parent b4d206a commit 016f497726932ea7380351f1a947265f3b4d114e
Showing with 4 additions and 1 deletion.
  1. +4 −1 src/server/qgswfsserver.cpp
@@ -1751,7 +1751,10 @@ QString QgsWFSServer::createFeatureGeoJSON( QgsFeature* feat, int prec, QgsCoord
else
{
fStr += "\"";
fStr += val.toString().replace( QString( "\"" ), QString( "\\\"" ) );
fStr += val.toString()
.replace( QString( "\"" ), QString( "\\\"" ) )

This comment has been minimized.

Copy link
@nyalldawson

nyalldawson Nov 11, 2015

Contributor

Please use replace( '\n',... ) instead. The single quote character methods are MUCH faster than the Qstring versions.

This comment has been minimized.

Copy link
@rldhont

rldhont Nov 12, 2015

Author Contributor

hi @nyalldawson, Thanks! I don't know about this.
Does it also work for \r and " ?

This comment has been minimized.

Copy link
@nyalldawson

nyalldawson Nov 12, 2015

Contributor

Yep, any single character (or single escaped character) will work. They take about 1/10th of the time of the string variant.

.replace( QString( "\r" ), QString( "\\r" ) )
.replace( QString( "\n" ), QString( "\\n" ) );
fStr += "\"";
}
fStr += "\n";

6 comments on commit 016f497

@jef-n

This comment has been minimized.

Copy link
Member

@jef-n jef-n replied Nov 12, 2015

Please also run "scripts/prepare-commit.sh" (it can also directly be linked to .git/hooks/pre-commit) - and include "fix #ticket" or "fixes #ticket" in the commit message so that redmine picks it up automatically.

@rldhont

This comment has been minimized.

Copy link
Contributor Author

@rldhont rldhont replied Nov 12, 2015

Hi @jef-n I thought there is a conflict between redmine and github about "fix #ticket".
I think this string will close a github issue or pull-request and the good redmine issue. am I wrong ?

@jef-n

This comment has been minimized.

Copy link
Member

@jef-n jef-n replied Nov 12, 2015

I think so. fix #xxx closes the redmine issue. I doubt there is a (enabled) automation for closing github issues (which we currently don't use for qgis anyway) or PRs. But the github web interface still mistakes #xxx in commits as links to PRs - but that's harmless.

@rldhont

This comment has been minimized.

Copy link
Contributor Author

@rldhont rldhont replied Nov 12, 2015

I use 'fixes #xxxx' to close github issues in my other projects, but there is also fix, fixed, closes, close, closed, resolve, resolves, resolved https://help.github.com/articles/closing-issues-via-commit-messages/ . I don't know if we can deactivate its

@jef-n

This comment has been minimized.

Copy link
Member

@jef-n jef-n replied Nov 12, 2015

But we use "fixes #xxxx" to close redmine issues (I think also Fix,implements - would have to look it up in redmine). See all over the commit log. I didn't hear from anyone that something else was closed by those - so I suppose it is not activated.

@rldhont

This comment has been minimized.

Copy link
Contributor Author

@rldhont rldhont replied Nov 12, 2015

Thanks, I'll do it.

Please sign in to comment.
You can’t perform that action at this time.