All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.shapesecurity.shift.codegen.WebSafeTokenStream Maven / Gradle / Ivy

There is a newer version: 2.2.0
Show newest version
package com.shapesecurity.shift.codegen;

import com.shapesecurity.shift.utils.Utils;
import org.jetbrains.annotations.NotNull;

class WebSafeTokenStream extends TokenStream {
	public WebSafeTokenStream(@NotNull StringBuilder writer) {
		super(writer);
	}

	@Override
	public void put(@NotNull String tokenStr) {
		if (
			this.lastChar == '<' && (tokenStr.startsWith("script") || tokenStr.startsWith("/script")) ||
            Utils.isIdentifierPart(this.lastChar) && (Utils.isIdentifierPart(tokenStr.charAt(0)) || tokenStr.charAt(0) == '\\')
		) {
			writer.append(this.lastChar = ' ');
		}
		super.put(tokenStr);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy