Skip to content

Commit

Permalink
refactor(src/ipc/bridge.cc): detect 'runtime-preload-injection' meta tag
Browse files Browse the repository at this point in the history
  • Loading branch information
jwerle committed Apr 15, 2024
1 parent 675b6eb commit d571c19
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/ipc/bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3754,6 +3754,12 @@ static void registerSchemeHandler (Router *router) {
{"protocol_handlers", join(protocolHandlers, " ")}
});

if (html.find("<meta name=\"runtime-preload-injection\" content=\"disabled\"") != String::npos) {
script = "";
} else if (html.find("<meta content=\"disabled\" name=\"runtime-preload-injection\"") != String::npos) {
script = "";
}

if (html.find("<head>") != String::npos) {
html = replace(html, "<head>", String("<head>" + script));
} else if (html.find("<body>") != String::npos) {
Expand Down Expand Up @@ -4446,6 +4452,12 @@ static void registerSchemeHandler (Router *router) {
{"protocol_handlers", join(protocolHandlers, " ")}
});

if (html.find("<meta name=\"runtime-preload-injection\" content=\"disabled\"") != String::npos) {
script = "";
} else if (html.find("<meta content=\"disabled\" name=\"runtime-preload-injection\"") != String::npos) {
script = "";
}

if (html.find("<head>") != String::npos) {
html = replace(html, "<head>", String("<head>" + script));
} else if (html.find("<body>") != String::npos) {
Expand Down Expand Up @@ -4875,6 +4887,12 @@ static void registerSchemeHandler (Router *router) {
{"protocol_handlers", join(protocolHandlers, " ")}
});

if (html.find("<meta name=\"runtime-preload-injection\" content=\"disabled\"") != String::npos) {
script = "";
} else if (html.find("<meta content=\"disabled\" name=\"runtime-preload-injection\"") != String::npos) {
script = "";
}

if (html.find("<head>") != String::npos) {
html = replace(html, "<head>", String("<head>" + script));
} else if (html.find("<body>") != String::npos) {
Expand Down

0 comments on commit d571c19

Please sign in to comment.