From be1c7e50e1e8809ea56f2c9d472eccd8ffd73a97 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 04:57:58 +0200 Subject: Adding upstream version 1.44.3. Signed-off-by: Daniel Baumann --- web/server/h2o/libh2o/misc/oktavia/src/sax.jsx | 1356 ++++++++++++++++++++++++ 1 file changed, 1356 insertions(+) create mode 100644 web/server/h2o/libh2o/misc/oktavia/src/sax.jsx (limited to 'web/server/h2o/libh2o/misc/oktavia/src/sax.jsx') diff --git a/web/server/h2o/libh2o/misc/oktavia/src/sax.jsx b/web/server/h2o/libh2o/misc/oktavia/src/sax.jsx new file mode 100644 index 00000000..d34cb825 --- /dev/null +++ b/web/server/h2o/libh2o/misc/oktavia/src/sax.jsx @@ -0,0 +1,1356 @@ +// When we pass the MAX_BUFFER_LENGTH position, start checking for buffer overruns. +// When we check, schedule the next check for MAX_BUFFER_LENGTH - (max(buffer lengths)), +// since that's the earliest that a buffer overrun could occur. This way, checks are +// as rare as required, but as often as necessary to ensure never crossing this bound. +// Furthermore, buffers are only tested at most once per write(), so passing a very +// large string into write() might have undesirable effects, but this is manageable by +// the caller, so it is assumed to be safe. Thus, a call to write() may, in the extreme +// edge case, result in creating at most one complete copy of the string passed in. +// Set to Infinity to have unlimited buffers. + + +class Tag +{ + var name : string; + var attributes : Map.; + var isSelfClosing : boolean; + function constructor (name : string) + { + this.name = name; + this.attributes = {} : Map.; + this.isSelfClosing = false; + } +} + +class _Common +{ + static const buffers = [ + "comment", "sgmlDecl", "textNode", "tagName", "doctype", + "procInstName", "procInstBody", "entity", "attribName", + "attribValue", "cdata", "script" + ]; + + static const EVENTS = // for discoverability. + [ "text", + "processinginstruction", + "sgmldeclaration", + "doctype", + "comment", + "attribute", + "opentag", + "closetag", + "opencdata", + "cdata", + "clo_State.CDATA", + "error", + "end", + "ready", + "script", + "opennamespace", + "closenamespace" + ]; + + static const MAX_BUFFER_LENGTH = 64 * 1024; +} + +class _State +{ + static const BEGIN = 1; + static const TEXT = 2; // general stuff + static const TEXT_ENTITY = 3; // & and such. + static const OPEN_WAKA = 4; // < + static const SGML_DECL = 5; // + static const SCRIPT = 33; //