Skip to content

Instantly share code, notes, and snippets.

@bdrewery
Created October 17, 2009 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bdrewery/212369 to your computer and use it in GitHub Desktop.
Save bdrewery/212369 to your computer and use it in GitHub Desktop.
patch for pecl-htscanner to fix php_flag parsing
--- htscanner.c.orig 2009-08-03 17:37:27.000000000 +0200
+++ htscanner.c 2009-08-03 17:37:55.000000000 +0200
@@ -103,10 +103,17 @@
if (flag) {
/* it's a flag */
- if (!strcasecmp(value, "On") || (value[0] == '1' && value[1] == '\0')) {
+
+ /*
+ * check only for valid boolean values.
+ * Boris HUISGEN <bhuisgen@hbis.fr>
+ */
+ if (!strcasecmp(value, "on")) {
value = "1";
- } else {
+ } else if (!strcasecmp(value, "off")) {
value = "0";
+ } else {
+ return FAILURE;
}
value_len = 1;
} else {
@@ -188,6 +195,10 @@
value_len = strlen(value);
if (value_len > 2 && value[value_len - 2] == '\r') {
value[value_len - 2] = 0;
+ } else if (value[value_len - 1] == '\n') {
+ value[value_len - 1] = 0;
+ } else if (value[value_len - 1] == '\r') {
+ value[value_len - 1] = 0;
} else {
value[value_len] = 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment