Index: trunk/extensions/SemanticMediaWiki/includes/export/SMW_Exp_Element.php |
— | — | @@ -169,6 +169,18 @@ |
170 | 170 | return $this->m_localname; |
171 | 171 | } |
172 | 172 | |
| 173 | + /** |
| 174 | + * Check if the local name is qualifies as a local name in XML and |
| 175 | + * Turtle. The function returns true if this is surely the case, and |
| 176 | + * false if it may not be the case. However, we do not check the whole |
| 177 | + * range of allowed Unicode entities for performance reasons. |
| 178 | + * |
| 179 | + * @return boolean |
| 180 | + */ |
| 181 | + public function hasAllowedLocalName() { |
| 182 | + return preg_match( '/^[A-Za-z_][-A-Za-z_0-9]*$/u', $this->m_localname ); |
| 183 | + } |
| 184 | + |
173 | 185 | } |
174 | 186 | |
175 | 187 | /** |
Index: trunk/extensions/SemanticMediaWiki/includes/export/SMW_Serializer_Turtle.php |
— | — | @@ -226,7 +226,7 @@ |
227 | 227 | if ( $element->isBlankNode() ) { |
228 | 228 | $this->post_ns_buffer .= '[]'; |
229 | 229 | } else { |
230 | | - if ( $element instanceof SMWExpNsResource ) { |
| 230 | + if ( ( $element instanceof SMWExpNsResource ) && ( $element->hasAllowedLocalName() ) ) { |
231 | 231 | $this->post_ns_buffer .= $element->getQName(); |
232 | 232 | } else { |
233 | 233 | $this->post_ns_buffer .= '<' . str_replace( '>', '\>', SMWExporter::expandURI( $element->getUri() ) ) . '>'; |