HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux wordpress-ubuntu-s-2vcpu-4gb-fra1-01 5.4.0-169-generic #187-Ubuntu SMP Thu Nov 23 14:52:28 UTC 2023 x86_64
User: root (0)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/zaklada/html/node_modules/jsdom/lib/jsdom/living/helpers/validate-names.js
"use strict";
const xnv = require("xml-name-validator");
const DOMException = require("../../web-idl/DOMException");

// https://dom.spec.whatwg.org/#validate

exports.name = function (name) {
  const result = xnv.name(name);
  if (!result.success) {
    throw new DOMException(DOMException.INVALID_CHARACTER_ERR,
      "\"" + name + "\" did not match the Name production: " + result.error);
  }
};

exports.qname = function (qname) {
  exports.name(qname);

  const result = xnv.qname(qname);
  if (!result.success) {
    throw new DOMException(DOMException.NAMESPACE_ERR,
      "\"" + qname + "\" did not match the QName production: " + result.error);
  }
};

exports.validateAndExtract = function (namespace, qualifiedName) {
  if (namespace === "") {
    namespace = null;
  }

  exports.qname(qualifiedName);

  let prefix = null;
  let localName = qualifiedName;

  const colonIndex = qualifiedName.indexOf(":");
  if (colonIndex !== -1) {
    prefix = qualifiedName.substring(0, colonIndex);
    localName = qualifiedName.substring(colonIndex + 1);
  }

  if (prefix !== null && namespace === null) {
    throw new DOMException(DOMException.NAMESPACE_ERR,
      "A namespace was given but a prefix was also extracted from the qualifiedName");
  }

  if (prefix === "xml" && namespace !== "http://www.w3.org/XML/1998/namespace") {
    throw new DOMException(DOMException.NAMESPACE_ERR,
      "A prefix of \"xml\" was given but the namespace was not the XML namespace");
  }

  if ((qualifiedName === "xmlns" || prefix === "xmlns") && namespace !== "http://www.w3.org/2000/xmlns/") {
    throw new DOMException(DOMException.NAMESPACE_ERR,
      "A prefix or qualifiedName of \"xmlns\" was given but the namespace was not the XMLNS namespace");
  }

  if (namespace === "http://www.w3.org/2000/xmlns/" && qualifiedName !== "xmlns" && prefix !== "xmlns") {
    throw new DOMException(DOMException.NAMESPACE_ERR,
      "The XMLNS namespace was given but neither the prefix nor qualifiedName was \"xmlns\"");
  }

  return { namespace, prefix, localName, qualifiedName };
};