!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 

uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 

uid=33(www-data) gid=33(www-data) groups=33(www-data) 

Safe-mode: OFF (not secure)

/usr/local/share/.cache/yarn/v6/npm-@lezer-html-1.3.3-integrity/node_modules/@lezer/html/test/   drwxr-xr-x
Free 13.06 GB of 57.97 GB (22.53%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     test-incremental.js (3.14 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
import {parser as baseParser} from "../dist/index.es.js"
import {TreeFragment} from "@lezer/common"

let parser = baseParser.configure({bufferLength: 2})

let r = n => Math.floor(Math.random() * n)

let tags = ["p", "ul", "li", "div", "span", "th", "tr", "body", "head", "title", "dd", "code", "em", "strong"]

function randomDoc(size) {
  let doc = ""
  if (!r(5)) doc += "<!doctype html>"
  let scope = []
  for (let i = 0; i < size; i++) {
    let sel = r(20)
    if (sel < 5) {
      let tag = tags[r(tags.length)]
      doc += `<${tag}${r(2) ? " a=b" : ""}>`
      scope.push(tag)
    } else if (sel < 10 && scope.length) {
      let name = scope.pop()
      doc += `</${r(5) ? name : "div"}>`
    } else if (sel == 10) {
      doc += `<img>`
    } else if (sel == 11) {
      doc += "<script>a()</script>"
    } else if (sel == 12) {
      doc += r(2) ? "&amp;" : "<!--@-->"
    } else {
      for (let i = r(6) + 1; i >= 0; i--)
        doc += String.fromCharCode(97 + r(26))
    }
  }
  while (scope.length) {
    let name = scope.pop()
    if (r(5)) doc += `</${name}>`
  }
  return doc
}

function check(doc, [tp, pos, txt], prevAST) {
  let change = {fromA: pos, toA: pos, fromB: pos, toB: pos}, newDoc
  if (tp == "insert") {
    newDoc = doc.slice(0, pos) + txt + doc.slice(pos)
    change.toA += txt.length
  } else if (tp == "del") {
    newDoc = doc.slice(0, pos) + doc.slice(pos + 1)
    change.toB++
  } else {
    newDoc = doc.slice(0, pos) + txt + doc.slice(pos + 1)
    change.toA += txt.length
    change.toB++
  }
  let fragments = TreeFragment.applyChanges(TreeFragment.addTree(prevAST || parser.parse(doc)), [change], 2)
  let ast = parser.parse(newDoc, fragments)
  let orig = parser.parse(newDoc)
  if (ast.toString() != orig.toString()) {
    throw new Error(`Mismatch:\n  ${ast}\nvs\n  ${orig}\ndocument: ${
      JSON.stringify(doc)}\naction: ${JSON.stringify([tp, pos, ch])}`)
  }
  return [newDoc, ast]
}

// Call this to just run random tests until a failing one is found.
// Not directly called in the tests because there's a bunch of
// circumstances in which uninteresting deviations in error recovery
// will create differing parses, so results have to be manually
// inspected.
function generate() {
  for (let count = 0, size = 2;; size = Math.min(40, size + 1)) {
    let doc = randomDoc(size), prev = null
    for (let i = 0; i < 2; i++) {
      console.log("Attempt", ++count)
      let action = [["del", "insert", "replace"][r(3)], r(doc.length - 1), "<>/piabc "[r(9)]]
      ;([doc, prev] = check(doc, action, prev))
    }
  }
}

describe("Incremental parsing", () => {
  it("doesn't get confused by reused opening tags", () => {
    check("<code><code>mgnbni</code></code>", ["del", 29])
  })

  it("can handle a renamed opening tag after a self-closing", () => {
    check("<p>one two three four five six seven<p>eight", ["replace", 37, "a"])
  })

  it("is okay with nameless elements", () => {
    check("<body><code><img></code><>body>", ["replace", 14, ">"])
    check("abcde<>fghij<", ["replace", 12, ">"])
  })

  it("doesn't get confused by an invalid close tag receiving a matching open tag", () => {
    check("<div><p>foo</body>", ["insert", 0, "<body>"])
  })
})

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0107 ]--