Browse Source

Merge pull request #1026 from divinity76/patch-3

urlencode stuff
Konrad Kuśnierz 1 year ago
parent
commit
83ae66e6ae
No account linked to committer's email address
1 changed files with 30 additions and 22 deletions
  1. 30
    22
      modules/client_stats/stats.lua

+ 30
- 22
modules/client_stats/stats.lua View File

@@ -65,33 +65,33 @@ function onConnect(protocol)
65 65
   end
66 66
 
67 67
   local post = ''
68
-  post = post .. 'uid='                .. UUID
68
+  post = post .. 'uid='                .. urlencode(UUID)
69 69
   post = post .. '&report_delay='      .. REPORT_DELAY
70
-  post = post .. '&os='                .. g_app.getOs()
71
-  post = post .. '&graphics_vendor='   .. g_graphics.getVendor()
72
-  post = post .. '&graphics_renderer=' .. g_graphics.getRenderer()
73
-  post = post .. '&graphics_version='  .. g_graphics.getVersion()
74
-  post = post .. '&painter_engine='    .. g_graphics.getPainterEngine()
75
-  post = post .. '&fps='               .. g_app.getBackgroundPaneFps()
76
-  post = post .. '&max_fps='           .. g_app.getBackgroundPaneMaxFps()
77
-  post = post .. '&fullscreen='        .. tostring(g_window.isFullscreen())
78
-  post = post .. '&window_width='      .. g_window.getWidth()
79
-  post = post .. '&window_height='     .. g_window.getHeight()
80
-  post = post .. '&player_name='       .. g_game.getCharacterName()
81
-  post = post .. '&world_name='        .. g_game.getWorldName()
82
-  post = post .. '&otserv_host='       .. G.host
70
+  post = post .. '&os='                .. urlencode(g_app.getOs())
71
+  post = post .. '&graphics_vendor='   .. urlencode(g_graphics.getVendor())
72
+  post = post .. '&graphics_renderer=' .. urlencode(g_graphics.getRenderer())
73
+  post = post .. '&graphics_version='  .. urlencode(g_graphics.getVersion())
74
+  post = post .. '&painter_engine='    .. urlencode(g_graphics.getPainterEngine())
75
+  post = post .. '&fps='               .. urlencode(g_app.getBackgroundPaneFps())
76
+  post = post .. '&max_fps='           .. urlencode(g_app.getBackgroundPaneMaxFps())
77
+  post = post .. '&fullscreen='        .. urlencode(tostring(g_window.isFullscreen()))
78
+  post = post .. '&window_width='      .. urlencode(g_window.getWidth())
79
+  post = post .. '&window_height='     .. urlencode(g_window.getHeight())
80
+  post = post .. '&player_name='       .. urlencode(g_game.getCharacterName())
81
+  post = post .. '&world_name='        .. urlencode(g_game.getWorldName())
82
+  post = post .. '&otserv_host='       .. urlencode(G.host)
83 83
   post = post .. '&otserv_port='       .. G.port
84
-  post = post .. '&otserv_protocol='   .. g_game.getProtocolVersion()
85
-  post = post .. '&otserv_client='     .. g_game.getClientVersion()
86
-  post = post .. '&build_version='     .. g_app.getVersion()
87
-  post = post .. '&build_revision='    .. g_app.getBuildRevision()
88
-  post = post .. '&build_commit='      .. g_app.getBuildCommit()
89
-  post = post .. '&build_date='        .. g_app.getBuildDate()
84
+  post = post .. '&otserv_protocol='   .. urlencode(g_game.getProtocolVersion())
85
+  post = post .. '&otserv_client='     .. urlencode(g_game.getClientVersion())
86
+  post = post .. '&build_version='     .. urlencode(g_app.getVersion())
87
+  post = post .. '&build_revision='    .. urlencode(g_app.getBuildRevision())
88
+  post = post .. '&build_commit='      .. urlencode(g_app.getBuildCommit())
89
+  post = post .. '&build_date='        .. urlencode(g_app.getBuildDate())
90 90
   post = post .. '&display_width='     .. g_window.getDisplayWidth()
91 91
   post = post .. '&display_height='    .. g_window.getDisplayHeight()
92
-  post = post .. '&cpu='               .. g_platform.getCPUName()
92
+  post = post .. '&cpu='               .. urlencode(g_platform.getCPUName())
93 93
   post = post .. '&mem='               .. g_platform.getTotalSystemMemory()
94
-  post = post .. '&os_name='           .. g_platform.getOSName()
94
+  post = post .. '&os_name='           .. urlencode(g_platform.getOSName())
95 95
   post = post .. getAdditionalData()
96 96
 
97 97
   local message = ''
@@ -121,3 +121,11 @@ end
121 121
 function onError(protocol, message, code)
122 122
   pdebug('Could not send statistics: ' .. message)
123 123
 end
124
+
125
+function urlencode(str)
126
+    local encodeChar=function(chr)
127
+	    return string.format("%%%X",string.byte(chr))
128
+    end
129
+	local output, t = string.gsub(str,"[^%w]",encodeChar)
130
+	return output
131
+end

Loading…
Cancel
Save