humanmade / aws-xray

HM Platform AWS X-Ray Integration
23 stars 4 forks source link

Allow backslash in names #48

Closed rmccue closed 4 years ago

rmccue commented 4 years ago

The allowed characters in the segment name sanitising code appears to have been copy and pasted from the AWS documentation. The backslashes here are escaping the character after them from PHP's perspective, but also need escaping from the regex engine. In most cases, this has no effect (because redundantly escaping a character doesn't do anything), but the backslash itself needs double-escaping.

This gives the following at the end of the regex:

+\\\\\\-@
 |  |||
 |  |\+----- Escape the range operator (-) to treat as a dash
 |  |
 \--+------- Escape the backslash from PHP, and from the regex engine

Before, Altis\bootstrap -> Altisbootstrap After, Altis\bootstrap -> Altis\bootstrap

rmccue commented 4 years ago

I do when it's not linked to a previous mistake you made 😉