Skip to content

Commit 997d643

Browse files
committed
SPEC-RELATION: escape LONG-NAME
1 parent 4d3f34b commit 997d643

3 files changed

Lines changed: 25 additions & 1 deletion

File tree

reqif/parsers/spec_relation_parser.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import html
12
from typing import List, Optional
23

34
from reqif.models.error_handling import ReqIFMissingTagException
@@ -96,7 +97,7 @@ def unparse(spec_relation: ReqIFSpecRelation):
9697
if spec_relation.last_change is not None:
9798
output += f' LAST-CHANGE="{spec_relation.last_change}"'
9899
if spec_relation.long_name is not None:
99-
output += f' LONG-NAME="{spec_relation.long_name}"'
100+
output += f' LONG-NAME="{html.escape(spec_relation.long_name)}"'
100101
output += ">\n"
101102

102103
children_tags: List[str]
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<REQ-IF xmlns="http://www.omg.org/spec/ReqIF/20110401/reqif.xsd" xmlns:configuration="http://eclipse.org/rmf/pror/toolextensions/1.0">
3+
<CORE-CONTENT>
4+
<REQ-IF-CONTENT>
5+
<SPEC-RELATIONS>
6+
<SPEC-RELATION IDENTIFIER="TEST_SPEC_RELATION_ID" LAST-CHANGE="2015-12-14T02:04:52.318+01:00" LONG-NAME="Test &amp; Test">
7+
<TARGET>
8+
<SPEC-OBJECT-REF>SPEC_OBJECT_B</SPEC-OBJECT-REF>
9+
</TARGET>
10+
<SOURCE>
11+
<SPEC-OBJECT-REF>SPEC_OBJECT_A</SPEC-OBJECT-REF>
12+
</SOURCE>
13+
<TYPE>
14+
<SPEC-RELATION-TYPE-REF>PARENT</SPEC-RELATION-TYPE-REF>
15+
</TYPE>
16+
</SPEC-RELATION>
17+
</SPEC-RELATIONS>
18+
</REQ-IF-CONTENT>
19+
</CORE-CONTENT>
20+
</REQ-IF>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
RUN: mkdir -p %S/output
2+
RUN: %reqif passthrough %S/sample.reqif %S/output/sample.reqif
3+
RUN: %diff %S/sample.reqif %S/output/sample.reqif

0 commit comments

Comments
 (0)