@@ -91,6 +91,8 @@ std::string DocumentNode::DoSubstitution(const std::string &text)
9191*/
9292std::string DocumentNode::DoOneSubstitution (const std::string &text)
9393{
94+ static std::string illegal_msg{" Illegal substitution expression" };
95+
9496 static std::string env_token{" env:" };
9597 static std::string env_with_replacement{" env:-" };
9698 static std::string replacement_token{" :-" };
@@ -108,25 +110,29 @@ std::string DocumentNode::DoOneSubstitution(const std::string &text)
108110
109111 if (len < 4 )
110112 {
111- goto illegal;
113+ OTEL_INTERNAL_LOG_ERROR (illegal_msg << " : " << text);
114+ throw InvalidSchemaException (illegal_msg);
112115 }
113116
114117 c = text[0 ];
115118 if (c != ' $' )
116119 {
117- goto illegal;
120+ OTEL_INTERNAL_LOG_ERROR (illegal_msg << " : " << text);
121+ throw InvalidSchemaException (illegal_msg);
118122 }
119123
120124 c = text[1 ];
121125 if (c != ' {' )
122126 {
123- goto illegal;
127+ OTEL_INTERNAL_LOG_ERROR (illegal_msg << " : " << text);
128+ throw InvalidSchemaException (illegal_msg);
124129 }
125130
126131 c = text[len - 1 ];
127132 if (c != ' }' )
128133 {
129- goto illegal;
134+ OTEL_INTERNAL_LOG_ERROR (illegal_msg << " : " << text);
135+ throw InvalidSchemaException (illegal_msg);
130136 }
131137
132138 begin_name = 2 ;
@@ -148,7 +154,8 @@ std::string DocumentNode::DoOneSubstitution(const std::string &text)
148154 c = text[begin_name];
149155 if (!std::isalpha (c) && c != ' _' )
150156 {
151- goto illegal;
157+ OTEL_INTERNAL_LOG_ERROR (illegal_msg << " : " << text);
158+ throw InvalidSchemaException (illegal_msg);
152159 }
153160
154161 end_name = begin_name + 1 ;
@@ -181,7 +188,8 @@ std::string DocumentNode::DoOneSubstitution(const std::string &text)
181188 pos = text.find (replacement_token, end_name);
182189 if (pos != end_name)
183190 {
184- goto illegal;
191+ OTEL_INTERNAL_LOG_ERROR (illegal_msg << " : " << text);
192+ throw InvalidSchemaException (illegal_msg);
185193 }
186194 // text is of the form ${ENV_NAME:-fallback}
187195 begin_fallback = pos + replacement_token.length ();
@@ -203,10 +211,6 @@ std::string DocumentNode::DoOneSubstitution(const std::string &text)
203211 fallback = " " ;
204212 }
205213 return fallback;
206-
207- illegal:
208- OTEL_INTERNAL_LOG_ERROR (" Illegal substitution expression: " << text);
209- throw InvalidSchemaException (" Illegal substitution expression" );
210214}
211215
212216bool DocumentNode::BooleanFromString (const std::string &value)
0 commit comments