Skip to content

Open-source AI browser agent for Chrome and Firefox (monorepo) 🧠

Keep .do hostnames out of the iframe urlFilter file-name list

Claude5bfb798ffc62
diff --git a/src/chrome/src/agent/permission-gate.js b/src/chrome/src/agent/permission-gate.js
index 3e8be8413..0d6bfc7e4 100644
--- a/src/chrome/src/agent/permission-gate.js
+++ b/src/chrome/src/agent/permission-gate.js
@@ -590,8 +590,8 @@ export function frameHostMatches(frameUrl, urlFilter) {
// "127.0.0.1:8080/x", "localhost") rather than a path or a file name
// ("iframe-inner.html", "/embed", "widget").
// Extensions that serve pages or documents. A suffix that is also a country
-// domain people use as a host (.pl, .py, .sh, .cc) is left out on purpose.
-const FILE_NAME_SUFFIX = /\.(?:html?|xhtml|shtml?|php[345]?|phtml|aspx?|ashx|asmx|axd|jspx?|jsf|faces|cfml?|cgi|fcgi|do|action|esp|nsf|js|mjs|css|json|xml|txt|svg|png|jpe?g|gif|webp|pdf)$/i;
+// domain people use as a host (.do, .pl, .py, .sh, .cc) is left out on purpose.
+const FILE_NAME_SUFFIX = /\.(?:html?|xhtml|shtml?|php[345]?|phtml|aspx?|ashx|asmx|axd|jspx?|jsf|faces|cfml?|cgi|fcgi|action|esp|nsf|js|mjs|css|json|xml|txt|svg|png|jpe?g|gif|webp|pdf)$/i;
function urlFilterNamesHost(filter) {
const first = filter.replace(/^[a-z][a-z0-9+.-]*:\/\//i, '').split(/[/?#]/)[0];
const host = first.replace(/:\d+$/, '');
diff --git a/src/firefox/src/agent/permission-gate.js b/src/firefox/src/agent/permission-gate.js
index 1235af3c7..917e586a5 100644
--- a/src/firefox/src/agent/permission-gate.js
+++ b/src/firefox/src/agent/permission-gate.js
@@ -575,8 +575,8 @@ export function frameHostMatches(frameUrl, urlFilter) {
// "127.0.0.1:8080/x", "localhost") rather than a path or a file name
// ("iframe-inner.html", "/embed", "widget").
// Extensions that serve pages or documents. A suffix that is also a country
-// domain people use as a host (.pl, .py, .sh, .cc) is left out on purpose.
-const FILE_NAME_SUFFIX = /\.(?:html?|xhtml|shtml?|php[345]?|phtml|aspx?|ashx|asmx|axd|jspx?|jsf|faces|cfml?|cgi|fcgi|do|action|esp|nsf|js|mjs|css|json|xml|txt|svg|png|jpe?g|gif|webp|pdf)$/i;
+// domain people use as a host (.do, .pl, .py, .sh, .cc) is left out on purpose.
+const FILE_NAME_SUFFIX = /\.(?:html?|xhtml|shtml?|php[345]?|phtml|aspx?|ashx|asmx|axd|jspx?|jsf|faces|cfml?|cgi|fcgi|action|esp|nsf|js|mjs|css|json|xml|txt|svg|png|jpe?g|gif|webp|pdf)$/i;
function urlFilterNamesHost(filter) {
const first = filter.replace(/^[a-z][a-z0-9+.-]*:\/\//i, '').split(/[/?#]/)[0];
const host = first.replace(/:\d+$/, '');
diff --git a/test/run.js b/test/run.js
index d7a0a5f9f..d62561052 100644
--- a/test/run.js
+++ b/test/run.js
@@ -2566,9 +2566,10 @@ test('iframe tools say how to name a frame host when urlFilter is only a path',
// The suggested filter matches, so the hint is never a dead end.
assert.equal(gate.frameHostMatches(frameUrl, '127.0.0.1:47615/iframe-inner.html') && frameUrl.includes('127.0.0.1:47615/iframe-inner.html'), true);
assert.match(gate.urlFilterHostHint('embed', ['https://forms.example/embed/v2']), /for example "forms\.example\/embed\/v2"/);
- for (const name of ['checkout.cfm', 'submit.do', 'order.action', 'frame.shtml', 'handler.ashx', 'pay.jspx']) {
+ for (const name of ['checkout.cfm', 'order.action', 'frame.shtml', 'handler.ashx', 'pay.jspx']) {
assert.match(gate.urlFilterHostHint(name, [`https://shop.example/x/${name}`]), new RegExp(`for example "shop\\.example/x/${name.replace('.', '\\.')}"`), `${build}: ${name} is a file name, not a host`);
}
+ assert.equal(gate.urlFilterHostHint('shop.do', ['https://evil.example/?next=shop.do']), '', `${build}: .do is a country domain, so shop.do names a host`);
// No hint when the filter names a host (even one no frame has: a page
// cannot steer "stripe.com" to its own frame that mentions it), when
// nothing contains the filter, or without a filter.