nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: fabricjs/fabric.js
Pull request #10300 (2024-11-29 03:04:04)

fix(color): Support uppercase keywords
In the CSS style, when I set the color of an element using uppercase keywords like PINK or YELLOW, they are correctly recognized. However, in Fabric, only lowercase color keywords are currently supported. Therefore, I fixed it to ensure it supports uppercase keywords as well.


[bug demo](https://codepen.io/zhe-he-the-vuer/pen/mybywqP)

codesandbox[bot]: #### Review or Edit in CodeSandbox

Open the branch in <a href="https://codesandbox.io/p/github/zhe-he/fabric.js/fix-color?mode=review&utm_source=gh_app">Web Editor</a> &bull; <a href="https://codesandbox.io/p/vscode?owner=zhe-he&repo=fabric.js&branch=fix-color&utm_source=gh_app">VS Code</a> &bull; <a href="https://codesandbox.io/p/vscode?owner=zhe-he&repo=fabric.js&branch=fix-color&insiders=true&utm_source=gh_app">Insiders</a><br>
Open <a href="https://codesandbox.io/p/devtool/preview/zhe-he/fabric.js/fix-color?task=preview&port=51423&redirect=true&utm_source=gh_app">Preview</a>

<!-- open-in-codesandbox:complete -->


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 267d1bf5e..2e9838dda 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,7 @@
 
 ## [next]
 
+- fix(Color): Support uppercase keywords [#10300](https://github.com/fabricjs/fabric.js/pull/10300)
 - fix(): The \_setLineDash method has additional side effects, altering the value of strokeDashArray [#10292](https://github.com/fabricjs/fabric.js/issues/10292)
 - fix(): for object caching over invalidating the cache [#10294](https://github.com/fabricjs/fabric.js/pull/10294)
 
diff --git a/src/color/Color.ts b/src/color/Color.ts
index 81421ec31..35bbf1512 100644
--- a/src/color/Color.ts
+++ b/src/color/Color.ts
@@ -42,6 +42,7 @@ export class Color {
    * @returns {TRGBAColorSource}
    */
   protected _tryParsingColor(color: string) {
+    color = color.toLowerCase();
     if (color in ColorNameMap) {
       color = ColorNameMap[color as keyof typeof ColorNameMap];
     }


Test patch:
diff --git a/src/color/color.test.ts b/src/color/color.test.ts
index db3ed81da..79ea181c5 100644
--- a/src/color/color.test.ts
+++ b/src/color/color.test.ts
@@ -55,4 +55,12 @@ describe('Color regex and conversion tests', () => {
     expect(color1.isUnrecognised).toBe(true);
     expect(color1.getSource().toString()).toBe([0, 0, 0, 1].toString());
   });
+
+  it('Create colors through keywords', () => {
+    const color1 = new Color('red');
+    const color2 = new Color('RED');
+    const red = 'rgb(255,0,0)';
+    expect(color1.toRgb()).toBe(red);
+    expect(color2.toRgb()).toBe(red);
+  });
 });
Repository: thelounge/thelounge
Pull request #2669 (2018-07-21 21:37:56)

refactor getHumanDate() to accept a timestamp; avoids possible test failure; more accurate log times


Patch:
diff --git a/src/log.js b/src/log.js
index 3c58b85b..80fae6b0 100644
--- a/src/log.js
+++ b/src/log.js
@@ -32,7 +32,7 @@ module.exports = {
 		read(options, callback);
 	},
 
-	getHumanDate() {
-		return moment().format("YYYY-MM-DD HH:mm:ss");
+	getHumanDate(ts) {
+		return moment(ts).format("YYYY-MM-DD HH:mm:ss");
 	},
 };
diff --git a/src/plugins/messageStorage/text.js b/src/plugins/messageStorage/text.js
index 97558e79..ee97ad31 100644
--- a/src/plugins/messageStorage/text.js
+++ b/src/plugins/messageStorage/text.js
@@ -41,7 +41,7 @@ class TextFileMessageStorage {
 			return;
 		}
 
-		let line = `[${log.getHumanDate()}] `;
+		let line = `[${log.getHumanDate(msg.time)}] `;
 
 		// message types from src/models/msg.js
 		switch (msg.type) {
@@ -97,7 +97,7 @@ class TextFileMessageStorage {
 
 		line += "\n";
 
-		fs.appendFile(path.join(logPath, `${cleanFilename(channel.name)}.log`), line, (e) => {
+		fs.appendFile(path.join(logPath, cleanFilename(channel.name)), line, (e) => {
 			if (e) {
 				log.error("Failed to write user log", e);
 			}
@@ -122,5 +122,5 @@ function cleanFilename(name) {
 	name = filenamify(name, {replacement: "_"});
 	name = name.toLowerCase();
 
-	return name;
+	return `${name}.log`;
 }


Test patch:
diff --git a/test/src/helperTest.js b/test/src/helperTest.js
index 93574639..0f1cb0fd 100644
--- a/test/src/helperTest.js
+++ b/test/src/helperTest.js
@@ -56,6 +56,6 @@ describe("Helper", function() {
 	});
 
 	describe("#getHumanDate()", function() {
-		expect(log.getHumanDate()).to.equal(moment().format("YYYY-MM-DD HH:mm:ss"));
+		expect(log.getHumanDate(moment(1455090480000).utc())).to.equal("2016-02-10 07:48:00");
 	});
 });
Repository: thelounge/thelounge
Pull request #2764 (2018-09-09 10:10:38)

Limit network name length and replace spaces in log folders
This makes sure we always have UUID in the name for de-duplication, and makes sure that folder names are always the same length (36 characters).

Also added tests for this.


Patch:
diff --git a/src/plugins/messageStorage/text.js b/src/plugins/messageStorage/text.js
index a90c5287..fc453014 100644
--- a/src/plugins/messageStorage/text.js
+++ b/src/plugins/messageStorage/text.js
@@ -31,8 +31,7 @@ class TextFileMessageStorage {
 			return;
 		}
 
-		const networkFolderName = cleanFilename(`${network.name}-${network.uuid.substring(network.name.length + 1)}`);
-		const logPath = path.join(Helper.getUserLogsPath(), this.client.name, networkFolderName);
+		const logPath = path.join(Helper.getUserLogsPath(), this.client.name, TextFileMessageStorage.getNetworkFolderName(network));
 
 		try {
 			fsextra.ensureDirSync(logPath);
@@ -114,6 +113,14 @@ class TextFileMessageStorage {
 	canProvideMessages() {
 		return false;
 	}
+
+	static getNetworkFolderName(network) {
+		// Limit network name in the folder name to 23 characters
+		// So we can still fit 12 characters of the uuid for de-duplication
+		const networkName = cleanFilename(network.name.substring(0, 23).replace(/ /g, "-"));
+
+		return `${networkName}-${network.uuid.substring(networkName.length + 1)}`;
+	}
 }
 
 module.exports = TextFileMessageStorage;


Test patch:
diff --git a/test/tests/textLogFolder.js b/test/tests/textLogFolder.js
new file mode 100644
index 00000000..38391c56
--- /dev/null
+++ b/test/tests/textLogFolder.js
@@ -0,0 +1,34 @@
+"use strict";
+
+const expect = require("chai").expect;
+const TextFileMessageStorage = require("../../src/plugins/messageStorage/text");
+
+describe("TextFileMessageStorage", function() {
+	it("should combine network name and uuid into a safe name", function() {
+		expect(TextFileMessageStorage.getNetworkFolderName({
+			name: "Freenode",
+			uuid: "f9042ec9-4016-45e0-a8a8-d378fb252628",
+		})).to.equal("freenode-4016-45e0-a8a8-d378fb252628");
+	});
+
+	it("network name should be cleaned up and lowercased", function() {
+		expect(TextFileMessageStorage.getNetworkFolderName({
+			name: "@ TeSt ../..\\<>:\"/\\|?*",
+			uuid: "f9042ec9-4016-45e0-a8a8-d378fb252628",
+		})).to.equal("@-test-.._..--45e0-a8a8-d378fb252628");
+	});
+
+	it("folder name may contain two dashes if on boundary", function() {
+		expect(TextFileMessageStorage.getNetworkFolderName({
+			name: "Freenod",
+			uuid: "f9042ec9-4016-45e0-a8a8-d378fb252628",
+		})).to.equal("freenod--4016-45e0-a8a8-d378fb252628");
+	});
+
+	it("should limit network name length", function() {
+		expect(TextFileMessageStorage.getNetworkFolderName({
+			name: "This network name is longer than the uuid itself but it should be limited",
+			uuid: "f9042ec9-4016-45e0-a8a8-d378fb252628",
+		})).to.equal("this-network-name-is-lo-d378fb252628");
+	});
+});
Repository: thelounge/thelounge
Pull request #3073 (2019-02-19 14:25:22)

extend custom highlight regex
As discussed and tested on irc, this extends matching for custom highlights. Main reason was that a word defined in custom highlights followed by e.g. a colon, a comma or an exclamation mark, such as `Jay: hi!` or `Hi Jay!`, wouldn't be caught by the regex.

Also, it adds a test for custom highlights.


Patch:
diff --git a/src/client.js b/src/client.js
index b80793c5..4887892c 100644
--- a/src/client.js
+++ b/src/client.js
@@ -401,7 +401,7 @@ Client.prototype.compileCustomHighlights = function() {
 		return;
 	}
 
-	client.highlightRegex = new RegExp(`(?:^| |\t)(?:${highlightsTokens.join("|")})(?:\t| |$)`, "i");
+	client.highlightRegex = new RegExp(`(?:^|[ .,+!?|/:<>(){}'"@&~-])(?:${highlightsTokens.join("|")})(?:$|[ .,+!?|/:<>(){}'"-])`, "i");
 };
 
 Client.prototype.more = function(data) {


Test patch:
diff --git a/test/tests/customhighlights.js b/test/tests/customhighlights.js
new file mode 100644
index 00000000..7be921ea
--- /dev/null
+++ b/test/tests/customhighlights.js
@@ -0,0 +1,77 @@
+"use strict";
+
+const expect = require("chai").expect;
+
+const Client = require("../../src/client");
+
+const client = new Client({}, "test", {clientSettings: {highlights: "foo, @all,   sp ace   , 고"}});
+
+describe("Custom highlights", function() {
+	it("should NOT highlight", function() {
+		const teststrings = [
+			"and foos stuff",
+			"test foobar",
+			"testfoo bar",
+			"fooö",
+			"wtf@all",
+			"foo고",
+			"test고",
+			"space",
+			"sp:ace",
+		];
+
+		for (const teststring of teststrings) {
+			expect(teststring).to.not.match(client.highlightRegex);
+		}
+	});
+
+	it("should highlight", function() {
+		const teststrings = [
+			"Hey foo hello",
+			"hey Foo: hi",
+			"hey Foo, hi",
+			"<foo> testing",
+			"foo",
+			"hey @all test",
+			"testing foo's stuff",
+			"\"foo\"",
+			"\"@all\"",
+			"foo!",
+			"www.foo.bar",
+			"www.bar.foo/page",
+			"고",
+			"test 고",
+			"고!",
+			"www.고.com",
+			"hey @Foo",
+			"hey ~Foo",
+			"hey +Foo",
+			"hello &foo",
+			"@all",
+			"@all wtf",
+			"wtf @all",
+			"@@all",
+			"@고",
+			"f00 sp ace: bar",
+		];
+
+		for (const teststring of teststrings) {
+			expect(teststring).to.match(client.highlightRegex);
+		}
+	});
+
+	it("should trim custom highlights in the compiled regex", function() {
+		expect(client.highlightRegex).to.match(/\(\?:foo\|@all\|sp ace\|고\)/);
+	});
+
+	it("should NOT compile a regex", function() {
+		// test updating the regex and invalid custom hl inputs
+		client.config.clientSettings.highlights = ",,";
+		client.compileCustomHighlights();
+		expect(client.highlightRegex).to.be.null;
+
+		client.config.clientSettings.highlights = "  ";
+		client.compileCustomHighlights();
+		expect(client.highlightRegex).to.be.null;
+	});
+});
Repository: thelounge/thelounge
Pull request #4038 (2020-08-17 09:58:03)

Sync changed network name to open clients


Patch:
diff --git a/client/js/socket-events/network.js b/client/js/socket-events/network.js
index 1646d08a..9f248657 100644
--- a/client/js/socket-events/network.js
+++ b/client/js/socket-events/network.js
@@ -64,3 +64,8 @@ socket.on("network:info", function (data) {
 		Vue.set(network, key, data[key]);
 	}
 });
+
+socket.on("network:name", function (data) {
+	const network = store.getters.findNetwork(data.uuid);
+	network.name = network.channels[0].name = data.name;
+});
diff --git a/src/models/network.js b/src/models/network.js
index f19adae5..a2e4a946 100644
--- a/src/models/network.js
+++ b/src/models/network.js
@@ -253,6 +253,7 @@ Network.prototype.createWebIrc = function (client) {
 };
 
 Network.prototype.edit = function (client, args) {
+	const oldNetworkName = this.name;
 	const oldNick = this.nick;
 	const oldRealname = this.realname;
 
@@ -279,6 +280,14 @@ Network.prototype.edit = function (client, args) {
 	// Sync lobby channel name
 	this.channels[0].name = this.name;
 
+	if (this.name !== oldNetworkName) {
+		// Send updated network name to all connected clients
+		client.emit("network:name", {
+			uuid: this.uuid,
+			name: this.name,
+		});
+	}
+
 	if (!this.validate(client)) {
 		return;
 	}


Test patch:
diff --git a/test/models/network.js b/test/models/network.js
index 44e59cf7..3308bbc6 100644
--- a/test/models/network.js
+++ b/test/models/network.js
@@ -109,10 +109,18 @@ describe("Network", function () {
 
 		it("editing a network should enforce correct types", function () {
 			let saveCalled = false;
+			let nameEmitCalled = false;
 
 			const network = new Network();
 			network.edit(
 				{
+					emit(name, data) {
+						if (name === "network:name") {
+							nameEmitCalled = true;
+							expect(data.uuid).to.equal(network.uuid);
+							expect(data.name).to.equal("Lounge Test Network");
+						}
+					},
 					save() {
 						saveCalled = true;
 					},
@@ -133,12 +141,13 @@ describe("Network", function () {
 					commands: "/command 1 2 3\r\n/ping HELLO\r\r\r\r/whois test\r\n\r\n",
 					ip: "newIp",
 					hostname: "newHostname",
-					guid: "newGuid",
+					uuid: "newuuid",
 				}
 			);
 
 			expect(saveCalled).to.be.true;
-			expect(network.guid).to.not.equal("newGuid");
+			expect(nameEmitCalled).to.be.true;
+			expect(network.uuid).to.not.equal("newuuid");
 			expect(network.ip).to.be.undefined;
 			expect(network.hostname).to.be.undefined;