| @@ 260-282 (lines=23) @@ | ||
| 257 | * |
|
| 258 | * @return string The escaped value. |
|
| 259 | */ |
|
| 260 | private function escape_value( $value ) { |
|
| 261 | ||
| 262 | // see http://www.w3.org/TR/rdf-sparql-query/ |
|
| 263 | // '\t' U+0009 (tab) |
|
| 264 | // '\n' U+000A (line feed) |
|
| 265 | // '\r' U+000D (carriage return) |
|
| 266 | // '\b' U+0008 (backspace) |
|
| 267 | // '\f' U+000C (form feed) |
|
| 268 | // '\"' U+0022 (quotation mark, double quote mark) |
|
| 269 | // "\'" U+0027 (apostrophe-quote, single quote mark) |
|
| 270 | // '\\' U+005C (backslash) |
|
| 271 | ||
| 272 | $escaped_value = str_replace( '\\', '\\\\', $value ); |
|
| 273 | $escaped_value = str_replace( '\'', '\\\'', $escaped_value ); |
|
| 274 | $escaped_value = str_replace( '"', '\\"', $escaped_value ); |
|
| 275 | $escaped_value = str_replace( "\f", '\\f', $escaped_value ); |
|
| 276 | $escaped_value = str_replace( "\b", '\\b', $escaped_value ); |
|
| 277 | $escaped_value = str_replace( "\r", '\\r', $escaped_value ); |
|
| 278 | $escaped_value = str_replace( "\n", '\\n', $escaped_value ); |
|
| 279 | $escaped_value = str_replace( "\t", '\\t', $escaped_value ); |
|
| 280 | ||
| 281 | return $escaped_value; |
|
| 282 | } |
|
| 283 | ||
| 284 | } |
|
| 285 | ||
| @@ 302-323 (lines=22) @@ | ||
| 299 | * |
|
| 300 | * @return string The escaped string. |
|
| 301 | */ |
|
| 302 | function wordlift_esc_sparql( $string ) { |
|
| 303 | // see http://www.w3.org/TR/rdf-sparql-query/ |
|
| 304 | // '\t' U+0009 (tab) |
|
| 305 | // '\n' U+000A (line feed) |
|
| 306 | // '\r' U+000D (carriage return) |
|
| 307 | // '\b' U+0008 (backspace) |
|
| 308 | // '\f' U+000C (form feed) |
|
| 309 | // '\"' U+0022 (quotation mark, double quote mark) |
|
| 310 | // "\'" U+0027 (apostrophe-quote, single quote mark) |
|
| 311 | // '\\' U+005C (backslash) |
|
| 312 | ||
| 313 | $string = str_replace( '\\', '\\\\', $string ); |
|
| 314 | $string = str_replace( '\'', '\\\'', $string ); |
|
| 315 | $string = str_replace( '"', '\\"', $string ); |
|
| 316 | $string = str_replace( "\f", '\\f', $string ); |
|
| 317 | $string = str_replace( "\b", '\\b', $string ); |
|
| 318 | $string = str_replace( "\r", '\\r', $string ); |
|
| 319 | $string = str_replace( "\n", '\\n', $string ); |
|
| 320 | $string = str_replace( "\t", '\\t', $string ); |
|
| 321 | ||
| 322 | return $string; |
|
| 323 | } |
|
| 324 | ||
| 325 | /** |
|
| 326 | * Escapes an URI for a SPARQL query. |
|