Read a series of HTML attributes, terminated by {@literal > }.
Each attribute is of the form {@literal identifier[=value] }.
"value" may be unquoted, single-quoted, or double-quoted.
336676
protected void htmlAttrs() {
        skipWhitespace();

        loop:
        while (isIdentifierStart(ch)) {
            int namePos = bp;
            String name = readAttributeName();
            skipWhitespace();
            StringBuilder value = new StringBuilder();
            if (ch == '=') {
                nextChar();
                skipWhitespace();
                if (ch == '\'' || ch == '"') {
                    char quote = ch;
                    nextChar();
                    while (bp < buflen && ch != quote) {
                        if (newline && ch == '@') {
                            // No point trying to read more.
                            // In fact, all attrs get discarded by the caller
                            // and superseded by a malformed.html node because
                            // the html tag itself is not terminated correctly.
                            break loop;
                        }
                        value.append(ch);
                        nextChar();
                    }
                    nextChar();
                } else {
                    while (bp < buflen && !isUnquotedAttrValueTerminator(ch)) {
                        value.append(ch);
                        nextChar();
                    }
                }
                skipWhitespace();
            }
            checkHtmlAttr(name, value.toString());
        }
    }
1178407
private Object readAnnotationElementValue() throws IOException {
        final int tag = (char) inputStreamOrByteBuffer.readUnsignedByte();
        switch (tag) {
        case 'B':
            return (byte) cpReadInt(inputStreamOrByteBuffer.readUnsignedShort());
        case 'C':
            return (char) cpReadInt(inputStreamOrByteBuffer.readUnsignedShort());
        case 'D':
            return Double.longBitsToDouble(cpReadLong(inputStreamOrByteBuffer.readUnsignedShort()));
        case 'F':
            return Float.intBitsToFloat(cpReadInt(inputStreamOrByteBuffer.readUnsignedShort()));
        case 'I':
            return cpReadInt(inputStreamOrByteBuffer.readUnsignedShort());
        case 'J':
            return cpReadLong(inputStreamOrByteBuffer.readUnsignedShort());
        case 'S':
            return (short) cpReadUnsignedShort(inputStreamOrByteBuffer.readUnsignedShort());
        case 'Z':
            return cpReadInt(inputStreamOrByteBuffer.readUnsignedShort()) != 0;
        case 's':
            return getConstantPoolString(inputStreamOrByteBuffer.readUnsignedShort());
        case 'e': {
            // Return type is AnnotationEnumVal.
            final String annotationClassName = getConstantPoolClassDescriptor(
                    inputStreamOrByteBuffer.readUnsignedShort());
            final String annotationConstName = getConstantPoolString(inputStreamOrByteBuffer.readUnsignedShort());
            return new AnnotationEnumValue(annotationClassName, annotationConstName);
        }
        case 'c':
            // Return type is AnnotationClassRef (for class references in annotations)
            final String classRefTypeDescriptor = getConstantPoolString(
                    inputStreamOrByteBuffer.readUnsignedShort());
            return new AnnotationClassRef(classRefTypeDescriptor);
        case '@':
            // Complex (nested) annotation. Return type is AnnotationInfo.
            return readAnnotation();
        case '[':
            // Return type is Object[] (of nested annotation element values)
            final int count = inputStreamOrByteBuffer.readUnsignedShort();
            final Object[] arr = new Object[count];
            for (int i = 0; i < count; ++i) {
                // Nested annotation element value
                arr[i] = readAnnotationElementValue();
            }
            return arr;
        default:
            throw new ClassfileFormatException("Class " + className + " has unknown annotation element type tag '"
                    + ((char) tag) + "': element size unknown, cannot continue reading class. "
                    + "Please report this at https://github.com/classgraph/classgraph/issues");
        }
    }
394583
def parse_id_literal(ast, _variables=None):
    """"""
    if isinstance(ast, (StringValueNode, IntValueNode)):
        return ast.value
    return INVALID
923775
function (scanner, quote) {
  if (quote) {
    if (scanner.peek() !== quote)
      return null;
    scanner.pos++;
  }

  var tokens = [];
  var charsTokenToExtend = null;

  var charRef;
  while (true) {
    var ch = scanner.peek();
    var templateTag;
    var curPos = scanner.pos;
    if (quote && ch === quote) {
      scanner.pos++;
      return tokens;
    } else if ((! quote) && (HTML_SPACE.test(ch) || ch === '>')) {
      return tokens;
    } else if (! ch) {
      scanner.fatal("Unclosed attribute in tag");
    } else if (quote ? ch === '\u0000' : ('\u0000"\'<=`'.indexOf(ch) >= 0)) {
      scanner.fatal("Unexpected character in attribute value");
    } else if (ch === '&' &&
               (charRef = getCharacterReference(scanner, true,
                                                quote || '>'))) {
      tokens.push(charRef);
      charsTokenToExtend = null;
    } else if (scanner.getTemplateTag &&
               ((templateTag = scanner.getTemplateTag(
                 scanner, TEMPLATE_TAG_POSITION.IN_ATTRIBUTE)) ||
                scanner.pos > curPos /* `{{! comment}}` */)) {
      if (templateTag) {
        tokens.push({t: 'TemplateTag',
                     v: assertIsTemplateTag(templateTag)});
        charsTokenToExtend = null;
      }
    } else {
      if (! charsTokenToExtend) {
        charsTokenToExtend = { t: 'Chars', v: '' };
        tokens.push(charsTokenToExtend);
      }
      charsTokenToExtend.v += (ch === '\r' ? '\n' : ch);
      scanner.pos++;
      if (quote && ch === '\r' && scanner.peek() === '\n')
        scanner.pos++;
    }
  }
}
800165
def attributes_source
      @attributes_source ||=
        begin
          _explicit_tag, static_attrs, rest =
            source_code.scan(/\A\s*(%[-:\w]+)?([-:\w\.\#]*)(.*)/m)[0]

          attr_types = {
            '{' => [:hash, %w[{ }]],
            '(' => [:html, %w[( )]],
            '[' => [:object_ref, %w[[ ]]],
          }

          attr_source = { static: static_attrs }
          while rest
            type, chars = attr_types[rest[0]]
            break unless type # Not an attribute opening character, so we're done

            # Can't define multiple of the same attribute type (e.g. two {...})
            break if attr_source[type]

            attr_source[type], rest = Haml::Util.balance(rest, *chars)
          end

          attr_source
        end
    end
829578
function getAttribute(buffer, i, l) {
  for (; i < l; i++) {
    let c = buffer[i];
    // space or /
    if (isSpaceCharacter(c) || c === 0x2F) {
      continue;
    }
    // ">"
    if (c === 0x3E) {
      i++;
      break;
    }
    let name = "";
    let value = "";
    nameLoop:for (; i < l; i++) {
      c = buffer[i];
      // "="
      if (c === 0x3D && name !== "") {
        i++;
        break;
      }
      // space
      if (isSpaceCharacter(c)) {
        for (i++; i < l; i++) {
          c = buffer[i];
          // space
          if (isSpaceCharacter(c)) {
            continue;
          }
          // not "="
          if (c !== 0x3D) {
            return { attr: { name, value }, i };
          }

          i++;
          break nameLoop;
        }
        break;
      }
      // / or >
      if (c === 0x2F || c === 0x3E) {
        return { attr: { name, value }, i };
      }
      // A-Z
      if (c >= 0x41 && c <= 0x5A) {
        name += String.fromCharCode(c + 0x20); // lowercase
      } else {
        name += String.fromCharCode(c);
      }
    }
    c = buffer[i];
    // space
    if (isSpaceCharacter(c)) {
      for (i++; i < l; i++) {
        c = buffer[i];
        // space
        if (isSpaceCharacter(c)) {
          continue;
        } else {
          break;
        }
      }
    }
    // " or '
    if (c === 0x22 || c === 0x27) {
      const quote = c;
      for (i++; i < l; i++) {
        c = buffer[i];

        if (c === quote) {
          i++;
          return { attr: { name, value }, i };
        }

        // A-Z
        if (c >= 0x41 && c <= 0x5A) {
          value += String.fromCharCode(c + 0x20); // lowercase
        } else {
          value += String.fromCharCode(c);
        }
      }
    }

    // >
    if (c === 0x3E) {
      return { attr: { name, value }, i };
    }

    // A-Z
    if (c >= 0x41 && c <= 0x5A) {
      value += String.fromCharCode(c + 0x20); // lowercase
    } else {
      value += String.fromCharCode(c);
    }

    for (i++; i < l; i++) {
      c = buffer[i];

      // space or >
      if (isSpaceCharacter(c) || c === 0x3E) {
        return { attr: { name, value }, i };
      }

      // A-Z
      if (c >= 0x41 && c <= 0x5A) {
        value += String.fromCharCode(c + 0x20); // lowercase
      } else {
        value += String.fromCharCode(c);
      }
    }
  }
  return { i };
}
1028376
private JsonToken readLiteral() throws IOException {
        value = nextLiteral(true);
        if (valueLength == 0) {
            throw syntaxError("Expected literal value");
        }
        token = decodeLiteral();
        if (token == JsonToken.STRING) {
            checkLenient();
        }
        return token;
    }
317528
public Attribute parseAttribute()
    throws IOException
  {
    int nameIndex = readShort();

    String name = _cp.getUtf8(nameIndex).getValue();

    if (name.equals("Code")) {
      CodeAttribute code = new CodeAttribute(name);
      code.read(this);
      return code;
    }
    else if (name.equals("Exceptions")) {
      ExceptionsAttribute code = new ExceptionsAttribute(name);
      code.read(this);
      return code;
    }
    else if (name.equals("Signature")) {
      SignatureAttribute attr = new SignatureAttribute();
      attr.read(this);
      return attr;
    }
    else if (name.equals("BootstrapMethods")) {
      BootstrapMethodAttribute attr = new BootstrapMethodAttribute();
      attr.read(this);
      return attr;
    }
    
    OpaqueAttribute attr = new OpaqueAttribute(name);
    
    int length = readInt();

    byte []bytes = new byte[length];
    
    read(bytes, 0, bytes.length);

    attr.setValue(bytes);

    return attr;
  }
199850
function(attr) {
        var html = this._escapedAttributes[attr];
        if (html) {
          return html;
        }
        var val = this.attributes[attr];
        var escaped;
        if (isNullOrUndefined(val)) {
          escaped = '';
        } else {
          escaped = _.escape(val.toString());
        }
        this._escapedAttributes[attr] = escaped;
        return escaped;
      }
296500
private void parseAttribute(final Attributes atts) {
        URI target = toURI(atts.getValue(ATTRIBUTE_NAME_COPY_TO));
        if (target == null) {
            return;
        }
        final String attrScope = atts.getValue(ATTRIBUTE_NAME_SCOPE);

        // external resource is filtered here.
        if (ATTR_SCOPE_VALUE_EXTERNAL.equals(attrScope) || ATTR_SCOPE_VALUE_PEER.equals(attrScope)
                // FIXME: testing for :// here is incorrect, rely on source scope instead
                || target.toString().contains(COLON_DOUBLE_SLASH) || target.toString().startsWith(SHARP)) {
            return;
        }

        final URI targetAbs = stripFragment(target.isAbsolute() ? target : currentFile.resolve(target));
        assert targetAbs.isAbsolute();

        final String attrFormat = getFormat(atts);

        if (isFormatDita(attrFormat)) {
            final URI source = toURI(atts.getValue(ATTRIBUTE_NAME_HREF));
            if (source != null) {
                if (source.toString().isEmpty()) {
                    logger.warn("Copy-to task [href=\"\" copy-to=\"" + targetAbs + "\"] was ignored.");
                } else {
                    final URI sourceAbs = stripFragment(currentFile.resolve(source));
                    assert sourceAbs.isAbsolute();
                    final URI copyToSourceAbs = copyToMap.get(targetAbs);
                    if (copyToSourceAbs != null) {
                        if (!sourceAbs.equals(copyToSourceAbs)) {
                            logger.warn(MessageUtils.getMessage("DOTX065W", source.toString(), targetAbs.toString()).toString());
                        }
                    } else if (atts.getValue(ATTRIBUTE_NAME_CHUNK) != null &&
                            atts.getValue(ATTRIBUTE_NAME_CHUNK).contains(CHUNK_TO_CONTENT)) {
                        // Ignore
                    } else {
                        copyToMap.put(targetAbs, sourceAbs);
                    }
                }
            }
        }
    }
298377
def attribute_value(string)

      attribute_value = ''
      position = 0
      length = string.length

      while position < length
      
        # x09 (ASCII TAB), 0x0A (ASCII LF), 0x0C (ASCII FF), 0x0D (ASCII CR), or 0x20 (ASCII space) then advance position to the next byte, then, repeat this step.
        if string[position] =~ /[\u{09}\u{0A}\u{0C}\u{0D}\u{20}]/
            
          position += 1

        elsif string[position] =~ /['"]/

          attribute_value, position = quoted_value(string[position, length])
          break

        elsif string[position] == '>'
          position += 1
          break

        else
          attribute_value, position = unquoted_value(string[position, length])
          break
        end
      end

      [attribute_value, position]
    end
1285341
private String readAttributeAsJson(Attribute attribute) throws UnsupportedKerasConfigurationException {
        synchronized (Hdf5Archive.LOCK_OBJECT) {
            VarLenType vl = attribute.getVarLenType();
            int bufferSizeMult = 1;
            String s;
            /* TODO: find a less hacky way to do this.
             * Reading variable length strings (from attributes) is a giant
             * pain. There does not appear to be any way to determine the
             * length of the string in advance, so we use a hack: choose a
             * buffer size and read the config. If Jackson fails to parse
             * it, then we must not have read the entire config. Increase
             * buffer and repeat.
             */
            while (true) {
                byte[] attrBuffer = new byte[bufferSizeMult * 2000];
                BytePointer attrPointer = new BytePointer(attrBuffer);
                attribute.read(vl, attrPointer);
                attrPointer.get(attrBuffer);
                s = new String(attrBuffer);
                ObjectMapper mapper = new ObjectMapper();
                mapper.enable(DeserializationFeature.FAIL_ON_READING_DUP_TREE_KEY);
                try {
                    mapper.readTree(s);
                    break;
                } catch (IOException e) {
                    //OK - we don't know how long the buffer needs to be, so we'll try again with larger buffer
                }
                bufferSizeMult *= 2;
                if (bufferSizeMult > 1024) {
                    throw new UnsupportedKerasConfigurationException("Could not read abnormally long HDF5 attribute");
                }
            }
            vl.deallocate();
            return s;
        }
    }
78237
protected function parseAttributeValue()
	{
		// Test whether the value is in quotes
		if ($this->text[$this->pos] === '"' || $this->text[$this->pos] === "'")
		{
			return $this->parseQuotedAttributeValue();
		}

		// Capture everything up to whichever comes first:
		//  - an endline
		//  - whitespace followed by a slash and a closing bracket
		//  - a closing bracket, optionally preceded by whitespace
		//  - whitespace followed by another attribute (name followed by equal sign)
		//
		// NOTE: this is for compatibility with some forums (such as vBulletin it seems)
		//       that do not put attribute values in quotes, e.g.
		//       [quote=John Smith;123456] (quoting "John Smith" from post #123456)
		if (!preg_match('#[^\\]\\n]*?(?=\\s*(?:\\s/)?\\]|\\s+[-\\w]+=)#', $this->text, $m, null, $this->pos))
		{
			throw new RuntimeException;
		}

		$attrValue  = $m[0];
		$this->pos += strlen($attrValue);

		return $attrValue;
	}
868434
@Override @DefinedBy(Api.COMPILER_TREE) @SuppressWarnings("fallthrough")
    public Void visitAttribute(AttributeTree tree, Void ignore) {
        HtmlTag currTag = tagStack.peek().tag;
        if (currTag != null) {
            Name name = tree.getName();
            HtmlTag.Attr attr = currTag.getAttr(name);
            if (attr != null) {
                if (env.htmlVersion == HtmlVersion.HTML4 && attr.name().contains("-")) {
                    env.messages.error(HTML, tree, "dc.attr.not.supported.html4", name);
                }
                boolean first = tagStack.peek().attrs.add(attr);
                if (!first)
                    env.messages.error(HTML, tree, "dc.attr.repeated", name);
            }
            // for now, doclint allows all attribute names beginning with "on" as event handler names,
            // without checking the validity or applicability of the name
            if (!name.toString().startsWith("on")) {
                AttrKind k = currTag.getAttrKind(name);
                switch (env.htmlVersion) {
                    case HTML4:
                        validateHtml4Attrs(tree, name, k);
                        break;

                    case HTML5:
                        validateHtml5Attrs(tree, name, k);
                        break;
                }
            }

            if (attr != null) {
                switch (attr) {
                    case NAME:
                        if (currTag != HtmlTag.A) {
                            break;
                        }
                        // fallthrough
                    case ID:
                        String value = getAttrValue(tree);
                        if (value == null) {
                            env.messages.error(HTML, tree, "dc.anchor.value.missing");
                        } else {
                            if (!validName.matcher(value).matches()) {
                                env.messages.error(HTML, tree, "dc.invalid.anchor", value);
                            }
                            if (!checkAnchor(value)) {
                                env.messages.error(HTML, tree, "dc.anchor.already.defined", value);
                            }
                        }
                        break;

                    case HREF:
                        if (currTag == HtmlTag.A) {
                            String v = getAttrValue(tree);
                            if (v == null || v.isEmpty()) {
                                env.messages.error(HTML, tree, "dc.attr.lacks.value");
                            } else {
                                Matcher m = docRoot.matcher(v);
                                if (m.matches()) {
                                    String rest = m.group(2);
                                    if (!rest.isEmpty())
                                        checkURI(tree, rest);
                                } else {
                                    checkURI(tree, v);
                                }
                            }
                        }
                        break;

                    case VALUE:
                        if (currTag == HtmlTag.LI) {
                            String v = getAttrValue(tree);
                            if (v == null || v.isEmpty()) {
                                env.messages.error(HTML, tree, "dc.attr.lacks.value");
                            } else if (!validNumber.matcher(v).matches()) {
                                env.messages.error(HTML, tree, "dc.attr.not.number");
                            }
                        }
                        break;

                    case BORDER:
                        if (currTag == HtmlTag.TABLE) {
                            String v = getAttrValue(tree);
                            try {
                                if (env.htmlVersion == HtmlVersion.HTML5
                                        && (v == null || (!v.isEmpty() && Integer.parseInt(v) != 1))) {
                                    env.messages.error(HTML, tree, "dc.attr.table.border.html5", attr);
                                }
                            } catch (NumberFormatException ex) {
                                env.messages.error(HTML, tree, "dc.attr.table.border.html5", attr);
                            }
                        }
                        break;
                }
            }
        }

        // TODO: basic check on value

        return super.visitAttribute(tree, ignore);
    }
28419
function handleSimpleAttribute() {
    SIMPLEATTR.lastIndex = nextchar-1;
    var matched = SIMPLEATTR.exec(chars);
    if (!matched) throw new Error("should never happen");
    var name = matched[1];
    if (!name) return false;
    var value = matched[2];
    var len = value.length;
    switch(value[0]) {
    case '"':
    case "'":
      value = value.substring(1, len-1);
      nextchar += (matched[0].length-1);
      tokenizer = after_attribute_value_quoted_state;
      break;
    default:
      tokenizer = before_attribute_name_state;
      nextchar += (matched[0].length-1);
      value = value.substring(0, len-1);
      break;
    }

    // Make sure there isn't already an attribute with this name
    // If there is, ignore this one.
    for(var i = 0; i < attributes.length; i++) {
      if (attributes[i][0] === name) return true;
    }

    attributes.push([name, value]);
    return true;
  }
1251042
private void readInstance(StreamTokenizer tokenizer, AttributeDataset data, Attribute[] attributes) throws IOException, ParseException {
        double[] x = responseIndex >= 0 ? new double[attributes.length - 1] : new double[attributes.length];
        double y = Double.NaN;
        
        // Get values for all attributes.
        for (int i = 0, k = 0; i < attributes.length; i++) {
            // Get next token
            if (i > 0) {
                getNextToken(tokenizer);
            }

            if (i == responseIndex) {
                if (tokenizer.ttype == '?') {
                    y = Double.NaN;
                } else {
                    y = attributes[i].valueOf(tokenizer.sval);
                }
            } else {
                if (tokenizer.ttype == '?') {
                    x[k++] = Double.NaN;
                } else {
                    x[k++] = attributes[i].valueOf(tokenizer.sval);
                }
            }
        }

        if (Double.isNaN(y)) data.add(x); else data.add(x, y);
    }
536856
protected function parseQuotedAttributeValue()
	{
		$quote    = $this->text[$this->pos];
		$valuePos = $this->pos + 1;
		while (1)
		{
			// Look for the next quote
			$this->pos = strpos($this->text, $quote, $this->pos + 1);
			if ($this->pos === false)
			{
				// No matching quote. Apparently that string never ends...
				throw new RuntimeException;
			}

			// Test for an odd number of backslashes before this character
			$n = 0;
			do
			{
				++$n;
			}
			while ($this->text[$this->pos - $n] === '\\');

			if ($n % 2)
			{
				// If $n is odd, it means there's an even number of backslashes. We can exit this
				// loop
				break;
			}
		}

		// Unescape special characters ' " and \
		$attrValue = preg_replace(
			'#\\\\([\\\\\'"])#',
			'$1',
			substr($this->text, $valuePos, $this->pos - $valuePos)
		);

		// Skip past the closing quote
		++$this->pos;

		return $attrValue;
	}