"Emails on push" service generates HTML mails with broken links
Summary
Emails generated by the "Emails on push" service contain broken links.
Steps to reproduce
- configure a gitlab system to send mails for any push event
- Project -> Settings -> Integrations -> Emails on push
- select "Active" and "Push"
- enter some recipients
- don't select Disable code diffs
- push a commit to the repository
Example Project
- n/a, can't configure mail notifications on gitlab.com, my own repository is not publicly available
What is the current bug behavior?
- the "a href" links in the HTML text of the mail in the "x changes files:" section are incomplete
- they don't contain a server URL, just the so-called fragment (#...)
</ul>
<h4>1 changed file:</h4>
<ul>
<li class=3D"file-stats">
<a href=3D"#8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d">
README.md
</a>
</li>
</ul>
<h4>Changes:</h4>
What is the expected correct behavior?
- link should be a complete URL including scheme, server name, path
Relevant logs and/or screenshots
- n/a
Results of GitLab environment info
Expand for output related to GitLab environment info
System information System: Scientific 7.3 Current User: gitlab Using RVM: no Ruby Version: 2.3.3p222 Gem Version: 2.6.6 Bundler Version:1.13.7 Rake Version: 10.5.0 Redis Version: 3.2.5 Git Version: 2.13.0 Sidekiq Version:5.0.0 Go Version: unknownGitLab information Version: 9.4.0 Revision: 9bbe2ac Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: postgresql URL: http://repository..../gitlab HTTP Clone URL: http://repository..../gitlab/some-group/some-project.git SSH Clone URL: gitlab@repository....:some-group/some-project.git Using LDAP: yes Using Omniauth: no
GitLab Shell Version: 5.3.1 Repository storage paths:
- default: /home/gitlab/data/git-data/repositories Hooks: /opt/gitlab/embedded/service/gitlab-shell/hooks Git: /opt/gitlab/embedded/bin/git
Results of GitLab application Check
Expand for output related to the GitLab application check
Checking GitLab Shell ...GitLab Shell version >= 5.3.1 ? ... OK (5.3.1) Repo base directory exists? default... yes Repo storage directories are symlinks? default... no Repo paths owned by gitlab:root, or gitlab:gitlab? default... yes Repo paths access is drwxrws---? default... yes hooks directories in repos are links: ... 12/1216 ... ok 12/1217 ... ok 12/1218 ... ok 12/1219 ... ok 12/1220 ... ok 12/1221 ... ok 12/1222 ... ok 12/1223 ... ok 12/1224 ... ok 12/1225 ... ok 12/1226 ... ok 12/1227 ... ok 12/1228 ... ok 12/1229 ... ok 12/1230 ... ok 12/1231 ... ok 12/1232 ... ok 12/1233 ... ok 12/1234 ... ok 12/1235 ... ok 12/1236 ... ok 12/1237 ... ok 12/1238 ... ok 12/1239 ... ok 12/1240 ... ok 12/1241 ... ok 12/1242 ... ok 12/1243 ... ok 12/1244 ... ok 12/1245 ... ok 12/1246 ... ok 12/1247 ... ok 12/1248 ... ok 12/1249 ... ok 12/1250 ... ok 12/1251 ... ok 12/1252 ... ok 12/1253 ... ok 12/1254 ... ok 12/1255 ... ok 12/1256 ... ok 12/1257 ... ok 12/1258 ... ok 12/1259 ... ok 12/1260 ... ok 12/1261 ... ok 12/1262 ... ok 12/1263 ... ok 12/1264 ... ok 12/1265 ... ok 12/1266 ... ok 12/1267 ... ok 12/1268 ... ok 12/1269 ... ok 12/1270 ... ok 12/1271 ... ok 12/1272 ... ok 12/1273 ... ok 12/1274 ... ok 12/1275 ... ok 12/1276 ... ok 12/1277 ... ok 12/1278 ... ok 12/1279 ... ok 12/1280 ... ok 12/1281 ... ok 12/1282 ... ok 12/1283 ... ok 12/1284 ... ok 12/1285 ... ok 12/1286 ... ok 12/1287 ... ok 12/1288 ... ok 12/1289 ... ok 12/1290 ... ok 12/1291 ... ok 12/1292 ... ok 12/1293 ... ok 12/1294 ... ok 12/1295 ... ok 12/1296 ... ok 12/1297 ... ok 12/1298 ... ok 12/1299 ... ok 12/1300 ... ok 12/1301 ... ok 12/1302 ... ok 12/1303 ... ok 12/1304 ... ok 12/1305 ... ok 12/1306 ... ok 12/1307 ... ok 12/1308 ... ok 12/1309 ... ok 12/1310 ... ok 12/1311 ... ok 12/1312 ... ok 12/1313 ... ok 12/1314 ... ok 12/1315 ... ok 12/1316 ... ok 12/1317 ... ok 12/1318 ... ok 12/1319 ... ok 12/1320 ... ok 12/1321 ... ok 12/1322 ... ok 12/1323 ... ok 11/1324 ... ok 3/1325 ... ok 4/1326 ... ok 19/1328 ... ok 19/1329 ... ok 13/1330 ... ok 19/1331 ... repository is empty 19/1332 ... repository is empty 27/1333 ... ok 14/1334 ... ok 18/1336 ... ok 31/1337 ... ok 16/1338 ... ok Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Check GitLab API access: OK Access to /var/opt/gitlab/.ssh/authorized_keys: OK Send ping to redis server: OK gitlab-shell self-check successful
Checking GitLab Shell ... Finished
Checking Sidekiq ...
Running? ... yes Number of Sidekiq processes ... 1
Checking Sidekiq ... Finished
Checking Reply by email ...
Reply by email is disabled in config/gitlab.yml
Checking Reply by email ... Finished
Checking LDAP ...
Server: ldapmain LDAP authentication... Success LDAP users with access to your GitLab server (only showing the first 100 results) [...] Checking LDAP ... Finished
Checking GitLab ...
Git configured correctly? ... yes Database config exists? ... yes All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... yes Log directory writable? ... yes Tmp directory writable? ... yes Uploads directory exists? ... yes Uploads directory has correct permissions? ... yes Uploads directory tmp has correct permissions? ... yes Init script exists? ... skipped (omnibus-gitlab has no init script) Init script up-to-date? ... skipped (omnibus-gitlab has no init script) Projects have namespace: ... 12/1216 ... yes 12/1217 ... yes 12/1218 ... yes 12/1219 ... yes 12/1220 ... yes 12/1221 ... yes 12/1222 ... yes 12/1223 ... yes 12/1224 ... yes 12/1225 ... yes 12/1226 ... yes 12/1227 ... yes 12/1228 ... yes 12/1229 ... yes 12/1230 ... yes 12/1231 ... yes 12/1232 ... yes 12/1233 ... yes 12/1234 ... yes 12/1235 ... yes 12/1236 ... yes 12/1237 ... yes 12/1238 ... yes 12/1239 ... yes 12/1240 ... yes 12/1241 ... yes 12/1242 ... yes 12/1243 ... yes 12/1244 ... yes 12/1245 ... yes 12/1246 ... yes 12/1247 ... yes 12/1248 ... yes 12/1249 ... yes 12/1250 ... yes 12/1251 ... yes 12/1252 ... yes 12/1253 ... yes 12/1254 ... yes 12/1255 ... yes 12/1256 ... yes 12/1257 ... yes 12/1258 ... yes 12/1259 ... yes 12/1260 ... yes 12/1261 ... yes 12/1262 ... yes 12/1263 ... yes 12/1264 ... yes 12/1265 ... yes 12/1266 ... yes 12/1267 ... yes 12/1268 ... yes 12/1269 ... yes 12/1270 ... yes 12/1271 ... yes 12/1272 ... yes 12/1273 ... yes 12/1274 ... yes 12/1275 ... yes 12/1276 ... yes 12/1277 ... yes 12/1278 ... yes 12/1279 ... yes 12/1280 ... yes 12/1281 ... yes 12/1282 ... yes 12/1283 ... yes 12/1284 ... yes 12/1285 ... yes 12/1286 ... yes 12/1287 ... yes 12/1288 ... yes 12/1289 ... yes 12/1290 ... yes 12/1291 ... yes 12/1292 ... yes 12/1293 ... yes 12/1294 ... yes 12/1295 ... yes 12/1296 ... yes 12/1297 ... yes 12/1298 ... yes 12/1299 ... yes 12/1300 ... yes 12/1301 ... yes 12/1302 ... yes 12/1303 ... yes 12/1304 ... yes 12/1305 ... yes 12/1306 ... yes 12/1307 ... yes 12/1308 ... yes 12/1309 ... yes 12/1310 ... yes 12/1311 ... yes 12/1312 ... yes 12/1313 ... yes 12/1314 ... yes 12/1315 ... yes 12/1316 ... yes 12/1317 ... yes 12/1318 ... yes 12/1319 ... yes 12/1320 ... yes 12/1321 ... yes 12/1322 ... yes 12/1323 ... yes 11/1324 ... yes 3/1325 ... yes 4/1326 ... yes 19/1328 ... yes 19/1329 ... yes 13/1330 ... yes 19/1331 ... yes 19/1332 ... yes 27/1333 ... yes 14/1334 ... yes 18/1336 ... yes 31/1337 ... yes 16/1338 ... yes Redis version >= 2.8.0? ... yes Ruby version >= 2.3.3 ? ... yes (2.3.3) Git version >= 2.7.3 ? ... yes (2.13.0) Active users: ... 21
Checking GitLab ... Finished
Possible fixes
%a{ href: "#{@message.target_url if @message.disable_diffs?}##{hexdigest(diff_file.file_path)}" }
- the code seems to add the target URL only when disable_diffs true is
- that's wrong, target_url should always be used since relative links in HTML mails don't work
- bug fix should be trivial: just remove the condition