Skip to content

Commit ea06a69

Browse files
committed
Reset YAML tag after resolution during query as to preserve original
state of document (for expected behavior of match(), log(), and save()).
1 parent 3eaee44 commit ea06a69

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/Infrastructure/HConfig/src/ESMCI_HConfig.C

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1643,8 +1643,11 @@ int HConfig::getSizeMapVal(
16431643

16441644
//-----------------------------------------------------------------------------
16451645
inline string HConfig::tagRef(YAML::Node &self){
1646-
string value = self.Tag();
1646+
string valueOrig = self.Tag();
1647+
string value = valueOrig;
1648+
bool mustReset = false;
16471649
if ((value == "?") || (value == "")){
1650+
mustReset = true;
16481651
// not a valid tag found -> implement implicit tag resolution
16491652
switch (self.Type()){
16501653
case YAML::NodeType::Null:
@@ -1673,16 +1676,21 @@ inline string HConfig::tagRef(YAML::Node &self){
16731676
}
16741677
value = self.Tag(); // determine final outcome
16751678
}else if (value == "!"){
1679+
mustReset = true;
16761680
// yaml-cpp seems to do this for a quoted string
16771681
self.SetTag("tag:yaml.org,2002:str");
16781682
value = self.Tag(); // determine final outcome
16791683
}
1684+
if (mustReset) self.SetTag(valueOrig);
16801685
return value;
16811686
}
16821687
//-----------------------------------------------------------------------------
16831688
inline string HConfig::tag(YAML::Node self){
1684-
string value = self.Tag();
1689+
string valueOrig = self.Tag();
1690+
string value = valueOrig;
1691+
bool mustReset = false;
16851692
if ((value == "?") || (value == "")){
1693+
mustReset = true;
16861694
// not a valid tag found -> implement implicit tag resolution
16871695
switch (self.Type()){
16881696
case YAML::NodeType::Null:
@@ -1711,10 +1719,12 @@ inline string HConfig::tag(YAML::Node self){
17111719
}
17121720
value = self.Tag(); // determine final outcome
17131721
}else if (value == "!"){
1722+
mustReset = true;
17141723
// yaml-cpp seems to do this for a quoted string
17151724
self.SetTag("tag:yaml.org,2002:str");
17161725
value = self.Tag(); // determine final outcome
17171726
}
1727+
if (mustReset) self.SetTag(valueOrig);
17181728
return value;
17191729
}
17201730
//-----------------------------------------------------------------------------

0 commit comments

Comments
 (0)