Skip to content

Commit f5d4765

Browse files
committed
Drop unsupported characters from XML
1 parent 3f1fa82 commit f5d4765

File tree

5 files changed

+51
-6
lines changed

5 files changed

+51
-6
lines changed

include/Properties.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace llvm2graphml {
77

88
class Properties {
99
public:
10-
void setStringProperty(const std::string &key, std::string value);
10+
void setStringProperty(const std::string &key, const std::string &value);
1111
void setBooleanProperty(const std::string &key, bool value);
1212
void setLongProperty(const std::string &key, uint64_t value);
1313

src/Properties.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,21 @@
33

44
using namespace llvm2graphml;
55

6-
void Properties::setStringProperty(const std::string& key, std::string value) {
7-
strings[key] = std::move(value);
6+
static std::string dropUnsupportedXmlChars(const std::string &input) {
7+
std::string output;
8+
output.reserve(input.size());
9+
for (char c : input) {
10+
if (iscntrl(c) && (c != 0x9) && (c != 0xa) && (c != 0xd)) {
11+
continue;
12+
}
13+
output.push_back(c);
14+
}
15+
16+
return output;
17+
}
18+
19+
void Properties::setStringProperty(const std::string &key, const std::string &value) {
20+
strings[key] = dropUnsupportedXmlChars(value);
821
}
922

1023
void Properties::setBooleanProperty(const std::string &key, bool value) {

tests/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ else()
77
include(ExternalProject)
88

99
ExternalProject_Add(gremlin
10-
URL http://mirror.funkfreundelandshut.de/apache/tinkerpop/3.4.5/apache-tinkerpop-gremlin-console-3.4.5-bin.zip
11-
URL_HASH MD5=1ad2e9b2414846aed32213e1b7b331eb
10+
URL https://downloads.apache.org/tinkerpop/3.4.6/apache-tinkerpop-gremlin-console-3.4.6-bin.zip
11+
URL_HASH MD5=e810f5cc9890a23bdf5f4aca1b4f0471
1212
CONFIGURE_COMMAND ""
1313
BUILD_COMMAND ""
1414
INSTALL_COMMAND ""
@@ -26,7 +26,7 @@ set(LIT_COMMAND
2626
GREMLIN_CONSOLE_EXEC=${GREMLIN_CONSOLE_EXEC}
2727
FILECHECK_EXEC=${FILECHECK_EXEC}
2828
${LIT_EXEC}
29-
-vv -j2
29+
-vv
3030
${CMAKE_CURRENT_LIST_DIR}/integration-tests
3131
)
3232

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
%0 = type opaque
2+
3+
define internal i32 @"\01-[Shape square]"(%0*, i8*) {
4+
%3 = alloca %0*, align 8
5+
%4 = alloca i8*, align 8
6+
store %0* %0, %0** %3, align 8
7+
store i8* %1, i8** %4, align 8
8+
ret i32 42
9+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
; RUN: cd %p
3+
; RUN: %LLVM2GRAPHML_EXEC --output=%t.xml main.ll
4+
; RUN: %GREMLIN_CONSOLE_EXEC -e %s %t.xml | %FILECHECK_EXEC %s --match-full-lines
5+
*/
6+
7+
/// Prepare
8+
9+
graph = TinkerGraph.open()
10+
g = graph.traversal()
11+
g.io(args[0]).read().iterate()
12+
13+
def dump(tr) {
14+
tr.unfold().sideEffect{println it}.iterate()
15+
}
16+
17+
/// Assertions
18+
19+
dump(g.V().has('function', 'name', '-[Shape square]').valueMap('name'))
20+
// CHECK: name=[-[Shape square]]
21+
22+
:exit
23+
// CHECK-EMPTY:

0 commit comments

Comments
 (0)