|
60 | 60 | placeholder="Leave blank for default graph"
|
61 | 61 | />
|
62 | 62 | <div class="invalid-feedback">
|
63 |
| - Invalid graph name. Please remove any spaces. |
| 63 | + Invalid graph name. Please remove any spaces and encoded values. |
64 | 64 | </div>
|
65 | 65 | </div>
|
66 | 66 | </div>
|
@@ -416,15 +416,38 @@ export default {
|
416 | 416 | return this.validateGraphName() && this.validateFiles()
|
417 | 417 | },
|
418 | 418 | validateGraphName () {
|
419 |
| - // No spaces allowed in graph names. |
420 |
| - const pattern = /^[^\s]+$/ |
421 | 419 | const graphName = this.$refs['dataset-graph-name'].value
|
422 |
| - if (graphName === '' || pattern.test(graphName)) { |
| 420 | + // An empty graph name is OK. |
| 421 | + if (graphName === '') { |
423 | 422 | this.graphNameClasses = ['form-control is-valid']
|
424 | 423 | return true
|
425 | 424 | }
|
426 |
| - this.graphNameClasses = ['form-control is-invalid'] |
427 |
| - return false |
| 425 | + // No spaces allowed in graph names. |
| 426 | + const pattern = /^\S+$/ |
| 427 | + if (!pattern.test(graphName)) { |
| 428 | + this.graphNameClasses = ['form-control is-invalid'] |
| 429 | + return false |
| 430 | + } |
| 431 | + // Only valid URIs allowed. |
| 432 | + try { |
| 433 | + new URL(graphName) |
| 434 | + } catch { |
| 435 | + this.graphNameClasses = ['form-control is-invalid'] |
| 436 | + return false |
| 437 | + } |
| 438 | + // Encoded components are not allowed. |
| 439 | + try { |
| 440 | + if (decodeURI(graphName) !== decodeURIComponent(graphName)) { |
| 441 | + this.graphNameClasses = ['form-control is-invalid'] |
| 442 | + return false |
| 443 | + } |
| 444 | + } catch { |
| 445 | + this.graphNameClasses = ['form-control is-invalid'] |
| 446 | + return false |
| 447 | + } |
| 448 | + // If it reached this part, then it's a valid graph name. |
| 449 | + this.graphNameClasses = ['form-control is-valid'] |
| 450 | + return true |
428 | 451 | },
|
429 | 452 | validateFiles () {
|
430 | 453 | if (this.upload.files !== null && this.upload.files.length > 0) {
|
|
0 commit comments