(ref string, path *url.URL)
| 330 | } |
| 331 | |
| 332 | func (loader *Loader) resolveRefPath(ref string, path *url.URL) (*url.URL, error) { |
| 333 | if ref != "" && ref[0] == '#' { |
| 334 | path = copyURI(path) |
| 335 | // Resolving internal refs of a doc loaded from memory |
| 336 | // has no path, so just set the Fragment. |
| 337 | if path == nil { |
| 338 | path = new(url.URL) |
| 339 | } |
| 340 | |
| 341 | path.Fragment = ref |
| 342 | return path, nil |
| 343 | } |
| 344 | |
| 345 | // IsExternalRefsAllowed is enforced here only when no custom ReadFromURIFunc |
| 346 | // is installed; otherwise the custom func owns the access policy (see the |
| 347 | // SECURITY note on the ReadFromURIFunc field). |
| 348 | if loader.ReadFromURIFunc == nil { |
| 349 | if err := loader.allowsExternalRefs(ref); err != nil { |
| 350 | return nil, err |
| 351 | } |
| 352 | } |
| 353 | |
| 354 | resolvedPath, err := loader.resolvePathWithRef(ref, path) |
| 355 | if err != nil { |
| 356 | return nil, err |
| 357 | } |
| 358 | |
| 359 | return resolvedPath, nil |
| 360 | } |
| 361 | |
| 362 | func isSingleRefElement(ref string) bool { |
| 363 | return !strings.Contains(ref, "#") |
no test coverage detected