diff options
-rw-r--r-- | map/bookmark.cpp | 5 | ||||
-rw-r--r-- | map/map_tests/bookmarks_test.cpp | 37 |
2 files changed, 40 insertions, 2 deletions
diff --git a/map/bookmark.cpp b/map/bookmark.cpp index e64f552fc4..8761f7d69d 100644 --- a/map/bookmark.cpp +++ b/map/bookmark.cpp @@ -231,7 +231,7 @@ namespace bookmark_impl else if (currTag == "description") m_description = value; } - else if (count > 3 && m_tags[2] == "Placemark") + else if (count > 3 && m_tags[count-3] == "Placemark") { if (prevTag == "Point") { @@ -265,7 +265,8 @@ void BookmarkCategory::LoadFromKML(ReaderPtr<Reader> const & reader) { ReaderSource<ReaderPtr<Reader> > src(reader); bookmark_impl::KMLParser parser(*this); - ParseXML(src, parser, true); + if (!ParseXML(src, parser, true)) + LOG(LERROR, ("XML read error. Probably, incorrect file encoding.")); } BookmarkCategory * BookmarkCategory::CreateFromKMLFile(string const & file) diff --git a/map/map_tests/bookmarks_test.cpp b/map/map_tests/bookmarks_test.cpp index 26a5e42017..d1226bbdfa 100644 --- a/map/map_tests/bookmarks_test.cpp +++ b/map/map_tests/bookmarks_test.cpp @@ -415,3 +415,40 @@ UNIT_TEST(Bookmarks_AddingMoving) DeleteCategoryFiles(); } + +namespace +{ +char const * kmlString2 = + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<kml xmlns=\"http://earth.google.com/kml/2.1\">" + "<Document>" + "<name>busparkplatz</name>" + "<Folder>" + "<name>Waypoint</name>" + "<Style id=\"poiIcon37\">" + "<IconStyle>" + "<scale>1</scale>" + "<Icon><href>http://maps.google.com/mapfiles/kml/shapes/placemark_circle.png</href></Icon>" + "<hotSpot x=\"0.5\" y=\"0\" xunits=\"fraction\" yunits=\"fraction\"/>" + "</IconStyle>" + "</Style>" + "<Placemark>" + "<name>[P] Silvrettastrae[Bieler Hhe]</name>" + "<description></description>" + "<styleUrl>#poiIcon37</styleUrl>" + "<Point>" + "<coordinates>10.09237,46.91741,0</coordinates>" + "</Point>" + "</Placemark>" + "</Folder>" + "</Document>" + "</kml>"; +} + +UNIT_TEST(Bookmarks_InnerFolder) +{ + BookmarkCategory cat("Default"); + cat.LoadFromKML(new MemReader(kmlString2, strlen(kmlString2))); + + TEST_EQUAL(cat.GetBookmarksCount(), 1, ()); +} |