BBlack has uploaded a new change for review.
https://gerrit.wikimedia.org/r/274087
Change subject: normalize_path: assert(url)
......................................................................
normalize_path: assert(url)
We were already assuming this assertion, as strlen(url) would have
crashed otherwise. Removes some excess indentation too.
Bug: T127387
Change-Id: I06b5db249d8a1cb8a3925a90f611d8283322e9f0
---
M templates/varnish/normalize_path.inc.vcl.erb
1 file changed, 36 insertions(+), 36 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/operations/puppet
refs/changes/87/274087/1
diff --git a/templates/varnish/normalize_path.inc.vcl.erb
b/templates/varnish/normalize_path.inc.vcl.erb
index baa4fb2..2f44e64 100644
--- a/templates/varnish/normalize_path.inc.vcl.erb
+++ b/templates/varnish/normalize_path.inc.vcl.erb
@@ -21,6 +21,8 @@
* MediaWiki purging only the wfUrlencode'd version of the URL.
*/
const char * url = VRT_r_req_url(sp);
+ assert(url);
+
size_t i, outPos;
const size_t urlLength = strlen(url);
// index for the last position %XX can start at:
@@ -33,47 +35,45 @@
* because this function can only shorten the input string.
*/
char destBuffer[urlLength + 1];
- if (url) {
- for (i = 0, outPos = 0; i < urlLength; i++) {
- if (i <= lastConvertIdx && url[i] == '%' &&
NP_IS_HEX(url[i+1]) && NP_IS_HEX(url[i+2])) {
- c = NP_HEXCHAR(url[i+1], url[i+2]);
- if (c == ';'
- || c == '@'
- || c == '$'
- || c == '!'
- || c == '*'
- || c == '('
- || c == ')'
- || c == ','
- || c == ':'
- || (doslash && c == '/'))
- {
- destBuffer[outPos++] = c;
- dirty = 1;
- i += 2;
- } else {
- destBuffer[outPos++] = url[i];
- }
- } else if (url[i] == '?' || url[i] = '#') {
- /* Reached the query/frag part. Just copy the
rest of the URL
- * to the destination.
- */
- memcpy(destBuffer + outPos, url + i,
sizeof(char) * (urlLength - i));
- outPos += urlLength - i;
- i = urlLength;
+ for (i = 0, outPos = 0; i < urlLength; i++) {
+ if (i <= lastConvertIdx && url[i] == '%' && NP_IS_HEX(url[i+1])
&& NP_IS_HEX(url[i+2])) {
+ c = NP_HEXCHAR(url[i+1], url[i+2]);
+ if (c == ';'
+ || c == '@'
+ || c == '$'
+ || c == '!'
+ || c == '*'
+ || c == '('
+ || c == ')'
+ || c == ','
+ || c == ':'
+ || (doslash && c == '/'))
+ {
+ destBuffer[outPos++] = c;
+ dirty = 1;
+ i += 2;
} else {
destBuffer[outPos++] = url[i];
}
+ } else if (url[i] == '?' || url[i] = '#') {
+ /* Reached the query/frag part. Just copy the rest of
the URL
+ * to the destination.
+ */
+ memcpy(destBuffer + outPos, url + i, sizeof(char) *
(urlLength - i));
+ outPos += urlLength - i;
+ i = urlLength;
+ } else {
+ destBuffer[outPos++] = url[i];
}
- destBuffer[outPos] = '\0';
+ }
+ destBuffer[outPos] = '\0';
- /* Set req.url. This will copy our stack buffer into the
workspace.
- * VRT_l_req_url() is varadic, and concatenates its arguments.
The
- * vrt_magic_string_end marks the end of the list.
- */
- if (dirty) {
- VRT_l_req_url(sp, destBuffer, vrt_magic_string_end);
- }
+ /* Set req.url. This will copy our stack buffer into the workspace.
+ * VRT_l_req_url() is varadic, and concatenates its arguments. The
+ * vrt_magic_string_end marks the end of the list.
+ */
+ if (dirty) {
+ VRT_l_req_url(sp, destBuffer, vrt_magic_string_end);
}
}
--
To view, visit https://gerrit.wikimedia.org/r/274087
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I06b5db249d8a1cb8a3925a90f611d8283322e9f0
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: BBlack <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits