Skip to content

GOWA - WhatsApp REST API with support for UI, Multi Account, Webhooks, and MCP, and Chatwoot. Built with Golang for efficient memory use.

fix: issue #512 encodeURIComponent

Aldino Kemala5532c01e1a2
diff --git a/src/ui/rest/middleware/device.go b/src/ui/rest/middleware/device.go
index e363b3ae..e9f48bde 100644
--- a/src/ui/rest/middleware/device.go
+++ b/src/ui/rest/middleware/device.go
@@ -1,6 +1,7 @@
package middleware
import (
+ "net/url"
"strings"
"github.com/aldinokemal/go-whatsapp-web-multidevice/infrastructure/whatsapp"
@@ -29,6 +30,10 @@ func DeviceMiddleware(dm *whatsapp.DeviceManager) fiber.Handler {
}
deviceID := strings.TrimSpace(c.Get(DeviceIDHeader))
+ // URL-decode the header value to support non-ASCII characters
+ if decoded, err := url.QueryUnescape(deviceID); err == nil {
+ deviceID = decoded
+ }
if deviceID == "" {
deviceID = strings.TrimSpace(c.Query("device_id"))
}
diff --git a/src/views/components/DeviceManager.js b/src/views/components/DeviceManager.js
index 64a5bd8e..5083037a 100644
--- a/src/views/components/DeviceManager.js
+++ b/src/views/components/DeviceManager.js
@@ -100,7 +100,7 @@ export default {
// Logout first (fire and forget), then delete
window.http.get(`/app/logout`, {
- headers: { 'X-Device-Id': deviceId }
+ headers: { 'X-Device-Id': encodeURIComponent(deviceId) }
}).catch(() => {});
await window.http.delete(`/devices/${encodeURIComponent(deviceId)}`);
diff --git a/src/views/index.html b/src/views/index.html
index 6811ddcc..d3f92f93 100644
--- a/src/views/index.html
+++ b/src/views/index.html
@@ -299,7 +299,7 @@
methods: {
applyDeviceHeader(id) {
if (id) {
- window.http.defaults.headers.common[DEVICE_ID_HEADER] = id;
+ window.http.defaults.headers.common[DEVICE_ID_HEADER] = encodeURIComponent(id);
} else {
delete window.http.defaults.headers.common[DEVICE_ID_HEADER];
if (this.app_ws) {