Gitweb links:

...log 
http://git.netsurf-browser.org/netsurf.git/shortlog/b024c0bcb5c8406e000bbc68e01f986833a09166
...commit 
http://git.netsurf-browser.org/netsurf.git/commit/b024c0bcb5c8406e000bbc68e01f986833a09166
...tree 
http://git.netsurf-browser.org/netsurf.git/tree/b024c0bcb5c8406e000bbc68e01f986833a09166

The branch, master has been updated
       via  b024c0bcb5c8406e000bbc68e01f986833a09166 (commit)
       via  8b4df800beeca19848928108addec6fb5f1184b8 (commit)
       via  0e7ebb4ee01904c746fe948f9343fd3418e735ae (commit)
       via  b14aa97a2a25cc0bcd258216aef7c70f9d354f1e (commit)
       via  8caae83d356c80536ac58a84801c861f0e6f0745 (commit)
       via  3ec522429ae933a3035c854aa78d136a06dee0db (commit)
      from  04d74a79ae95514af73476dafbdaea3a19e54b34 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=b024c0bcb5c8406e000bbc68e01f986833a09166
commit b024c0bcb5c8406e000bbc68e01f986833a09166
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>

    Tests: Add nsurl tests for unnecessary and bad escape values.

diff --git a/test/nsurl.c b/test/nsurl.c
index 4fbf3e1..a96ea34 100644
--- a/test/nsurl.c
+++ b/test/nsurl.c
@@ -153,6 +153,12 @@ static const struct test_pairs create_tests[] = {
        /* punycode */
        { "http://a.कॉम/a";, "http://a.xn--11b4c3d/a"; },
        { "https://smog.大众汽车/test";, "https://smog.xn--3oq18vl8pn36a/test"},
+
+       /* unnecessary escape */
+       { "http://%7a%7A/";, "http://zz/"; },
+
+       /* bad escape */
+       { "http://%1g%G0/";, "http://%1g%g0/"; },
 };
 
 /**


commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=8b4df800beeca19848928108addec6fb5f1184b8
commit 8b4df800beeca19848928108addec6fb5f1184b8
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>

    nsurl: Use ascii header for hex to value conversion.

diff --git a/utils/nsurl/parse.c b/utils/nsurl/parse.c
index a56a78d..7e78732 100644
--- a/utils/nsurl/parse.c
+++ b/utils/nsurl/parse.c
@@ -594,45 +594,6 @@ static size_t nsurl__get_longest_section(struct 
url_markers *m)
 
 
 /**
- * Converts two hexadecimal digits to a single number
- *
- * \param c1   most significant hex digit
- * \param c2   least significant hex digit
- * \return the total value of the two digit hex number, or -ve if input not hex
- *
- * For unescaping url encoded characters.
- */
-static inline int nsurl__get_ascii_offset(char c1, char c2)
-{
-       int offset;
-
-       /* Use 1st char as most significant hex digit */
-       if (ascii_is_digit(c1))
-               offset = 16 * (c1 - '0');
-       else if (c1 >= 'a' && c1 <= 'f')
-               offset = 16 * (c1 - 'a' + 10);
-       else if (c1 >= 'A' && c1 <= 'F')
-               offset = 16 * (c1 - 'A' + 10);
-       else
-               /* Not valid hex */
-               return -1;
-
-       /* Use 2nd char as least significant hex digit and sum */
-       if (ascii_is_digit(c2))
-               offset += c2 - '0';
-       else if (c2 >= 'a' && c2 <= 'f')
-               offset += c2 - 'a' + 10;
-       else if (c2 >= 'A' && c2 <= 'F')
-               offset += c2 - 'A' + 10;
-       else
-               /* Not valid hex */
-               return -1;
-
-       return offset;
-}
-
-
-/**
  * Create the components of a NetSurf URL object for a section of a URL string
  *
  * \param url_s                URL string
@@ -716,7 +677,7 @@ static nserror nsurl__create_from_section(const char * 
const url_s,
                        /* Might be an escaped character needing unescaped */
 
                        /* Find which character which was escaped */
-                       ascii_offset = nsurl__get_ascii_offset(*(pos + 1),
+                       ascii_offset = ascii_hex_to_value_2_chars(*(pos + 1),
                                        *(pos + 2));
 
                        if (ascii_offset < 0) {


commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=0e7ebb4ee01904c746fe948f9343fd3418e735ae
commit 0e7ebb4ee01904c746fe948f9343fd3418e735ae
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>

    ASCII: Add function for converting two hex chars to value.

diff --git a/utils/ascii.h b/utils/ascii.h
index e5f9949..94d988a 100644
--- a/utils/ascii.h
+++ b/utils/ascii.h
@@ -188,6 +188,19 @@ static inline int ascii_hex_to_value(char c)
 }
 
 /**
+ * Converts two hexadecimal characters to a single number
+ *
+ * \param[in] c1  most significant hex digit.
+ * \param[in] c2  least significant hex digit.
+ * \return the total value of the two digit hex number (0-255),
+ *         or -ve if input not hex.
+ */
+static inline int ascii_hex_to_value_2_chars(char c1, char c2)
+{
+       return 16 * ascii_hex_to_value(c1) + ascii_hex_to_value(c2);
+}
+
+/**
  * Convert an upper case character to lower case.
  *
  * If the given character is not upper case alphabetical, it is returned


commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=b14aa97a2a25cc0bcd258216aef7c70f9d354f1e
commit b14aa97a2a25cc0bcd258216aef7c70f9d354f1e
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>

    ASCII: Add hex char to value conversion function.

diff --git a/utils/ascii.h b/utils/ascii.h
index 6f7bf6d..e5f9949 100644
--- a/utils/ascii.h
+++ b/utils/ascii.h
@@ -168,6 +168,26 @@ static inline bool ascii_is_hex(char c)
 }
 
 /**
+ * Convert a hexadecimal character to its value.
+ *
+ * \param[in] c  Character to convert.
+ * \return value of character (0-15), or -256 if not a hexadecimal character.
+ */
+static inline int ascii_hex_to_value(char c)
+{
+       if (ascii_is_digit(c)) {
+               return c - '0';
+       } else if (ascii_is_af_lower(c)) {
+               return c - 'a' + 10;
+       } else if (ascii_is_af_upper(c)) {
+               return c - 'A' + 10;
+       }
+
+       /* Invalid hex */
+       return -256;
+}
+
+/**
  * Convert an upper case character to lower case.
  *
  * If the given character is not upper case alphabetical, it is returned


commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=8caae83d356c80536ac58a84801c861f0e6f0745
commit 8caae83d356c80536ac58a84801c861f0e6f0745
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>

    ASCII: Split out a-f test.

diff --git a/utils/ascii.h b/utils/ascii.h
index 55ca89c..6f7bf6d 100644
--- a/utils/ascii.h
+++ b/utils/ascii.h
@@ -111,6 +111,17 @@ static inline bool ascii_is_alphanumerical(char c)
 }
 
 /**
+ * Test whether a character is 'a' to 'f' (lowercase).
+ *
+ * \param[in] c  Character to test.
+ * \return true iff `c` is 'a' to 'f' (lowercase), else false.
+ */
+static inline bool ascii_is_af_lower(char c)
+{
+       return (c >= 'a' && c <= 'f');
+}
+
+/**
  * Test whether a character is hexadecimal (lower case).
  *
  * \param[in] c  Character to test.
@@ -118,8 +129,7 @@ static inline bool ascii_is_alphanumerical(char c)
  */
 static inline bool ascii_is_hex_lower(char c)
 {
-       return (ascii_is_digit(c) ||
-                       (c >= 'a' && c <= 'f'));
+       return (ascii_is_digit(c) || ascii_is_af_lower(c));
 }
 
 /**
@@ -154,7 +164,7 @@ static inline bool ascii_is_hex(char c)
 {
        return (ascii_is_digit(c) ||
                        ascii_is_af_upper(c) ||
-                       (c >= 'a' && c <= 'f'));
+                       ascii_is_af_lower(c));
 }
 
 /**


commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=3ec522429ae933a3035c854aa78d136a06dee0db
commit 3ec522429ae933a3035c854aa78d136a06dee0db
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>

    ASCII: Split out A-F test.

diff --git a/utils/ascii.h b/utils/ascii.h
index f08e756..55ca89c 100644
--- a/utils/ascii.h
+++ b/utils/ascii.h
@@ -123,6 +123,17 @@ static inline bool ascii_is_hex_lower(char c)
 }
 
 /**
+ * Test whether a character is 'A' to 'F' (uppercase).
+ *
+ * \param[in] c  Character to test.
+ * \return true iff `c` is 'A' to 'F' (uppercase), else false.
+ */
+static inline bool ascii_is_af_upper(char c)
+{
+       return (c >= 'A' && c <= 'F');
+}
+
+/**
  * Test whether a character is hexadecimal (upper case).
  *
  * \param[in] c  Character to test.
@@ -130,8 +141,7 @@ static inline bool ascii_is_hex_lower(char c)
  */
 static inline bool ascii_is_hex_upper(char c)
 {
-       return (ascii_is_digit(c) ||
-                       (c >= 'A' && c <= 'F'));
+       return (ascii_is_digit(c) || ascii_is_af_upper(c));
 }
 
 /**
@@ -143,7 +153,7 @@ static inline bool ascii_is_hex_upper(char c)
 static inline bool ascii_is_hex(char c)
 {
        return (ascii_is_digit(c) ||
-                       (c >= 'A' && c <= 'F') ||
+                       ascii_is_af_upper(c) ||
                        (c >= 'a' && c <= 'f'));
 }
 


-----------------------------------------------------------------------

Summary of changes:
 test/nsurl.c        |    6 +++++
 utils/ascii.h       |   65 ++++++++++++++++++++++++++++++++++++++++++++++-----
 utils/nsurl/parse.c |   41 +-------------------------------
 3 files changed, 66 insertions(+), 46 deletions(-)

diff --git a/test/nsurl.c b/test/nsurl.c
index 4fbf3e1..a96ea34 100644
--- a/test/nsurl.c
+++ b/test/nsurl.c
@@ -153,6 +153,12 @@ static const struct test_pairs create_tests[] = {
        /* punycode */
        { "http://a.कॉम/a";, "http://a.xn--11b4c3d/a"; },
        { "https://smog.大众汽车/test";, "https://smog.xn--3oq18vl8pn36a/test"},
+
+       /* unnecessary escape */
+       { "http://%7a%7A/";, "http://zz/"; },
+
+       /* bad escape */
+       { "http://%1g%G0/";, "http://%1g%g0/"; },
 };
 
 /**
diff --git a/utils/ascii.h b/utils/ascii.h
index f08e756..94d988a 100644
--- a/utils/ascii.h
+++ b/utils/ascii.h
@@ -111,6 +111,17 @@ static inline bool ascii_is_alphanumerical(char c)
 }
 
 /**
+ * Test whether a character is 'a' to 'f' (lowercase).
+ *
+ * \param[in] c  Character to test.
+ * \return true iff `c` is 'a' to 'f' (lowercase), else false.
+ */
+static inline bool ascii_is_af_lower(char c)
+{
+       return (c >= 'a' && c <= 'f');
+}
+
+/**
  * Test whether a character is hexadecimal (lower case).
  *
  * \param[in] c  Character to test.
@@ -118,8 +129,18 @@ static inline bool ascii_is_alphanumerical(char c)
  */
 static inline bool ascii_is_hex_lower(char c)
 {
-       return (ascii_is_digit(c) ||
-                       (c >= 'a' && c <= 'f'));
+       return (ascii_is_digit(c) || ascii_is_af_lower(c));
+}
+
+/**
+ * Test whether a character is 'A' to 'F' (uppercase).
+ *
+ * \param[in] c  Character to test.
+ * \return true iff `c` is 'A' to 'F' (uppercase), else false.
+ */
+static inline bool ascii_is_af_upper(char c)
+{
+       return (c >= 'A' && c <= 'F');
 }
 
 /**
@@ -130,8 +151,7 @@ static inline bool ascii_is_hex_lower(char c)
  */
 static inline bool ascii_is_hex_upper(char c)
 {
-       return (ascii_is_digit(c) ||
-                       (c >= 'A' && c <= 'F'));
+       return (ascii_is_digit(c) || ascii_is_af_upper(c));
 }
 
 /**
@@ -143,8 +163,41 @@ static inline bool ascii_is_hex_upper(char c)
 static inline bool ascii_is_hex(char c)
 {
        return (ascii_is_digit(c) ||
-                       (c >= 'A' && c <= 'F') ||
-                       (c >= 'a' && c <= 'f'));
+                       ascii_is_af_upper(c) ||
+                       ascii_is_af_lower(c));
+}
+
+/**
+ * Convert a hexadecimal character to its value.
+ *
+ * \param[in] c  Character to convert.
+ * \return value of character (0-15), or -256 if not a hexadecimal character.
+ */
+static inline int ascii_hex_to_value(char c)
+{
+       if (ascii_is_digit(c)) {
+               return c - '0';
+       } else if (ascii_is_af_lower(c)) {
+               return c - 'a' + 10;
+       } else if (ascii_is_af_upper(c)) {
+               return c - 'A' + 10;
+       }
+
+       /* Invalid hex */
+       return -256;
+}
+
+/**
+ * Converts two hexadecimal characters to a single number
+ *
+ * \param[in] c1  most significant hex digit.
+ * \param[in] c2  least significant hex digit.
+ * \return the total value of the two digit hex number (0-255),
+ *         or -ve if input not hex.
+ */
+static inline int ascii_hex_to_value_2_chars(char c1, char c2)
+{
+       return 16 * ascii_hex_to_value(c1) + ascii_hex_to_value(c2);
 }
 
 /**
diff --git a/utils/nsurl/parse.c b/utils/nsurl/parse.c
index a56a78d..7e78732 100644
--- a/utils/nsurl/parse.c
+++ b/utils/nsurl/parse.c
@@ -594,45 +594,6 @@ static size_t nsurl__get_longest_section(struct 
url_markers *m)
 
 
 /**
- * Converts two hexadecimal digits to a single number
- *
- * \param c1   most significant hex digit
- * \param c2   least significant hex digit
- * \return the total value of the two digit hex number, or -ve if input not hex
- *
- * For unescaping url encoded characters.
- */
-static inline int nsurl__get_ascii_offset(char c1, char c2)
-{
-       int offset;
-
-       /* Use 1st char as most significant hex digit */
-       if (ascii_is_digit(c1))
-               offset = 16 * (c1 - '0');
-       else if (c1 >= 'a' && c1 <= 'f')
-               offset = 16 * (c1 - 'a' + 10);
-       else if (c1 >= 'A' && c1 <= 'F')
-               offset = 16 * (c1 - 'A' + 10);
-       else
-               /* Not valid hex */
-               return -1;
-
-       /* Use 2nd char as least significant hex digit and sum */
-       if (ascii_is_digit(c2))
-               offset += c2 - '0';
-       else if (c2 >= 'a' && c2 <= 'f')
-               offset += c2 - 'a' + 10;
-       else if (c2 >= 'A' && c2 <= 'F')
-               offset += c2 - 'A' + 10;
-       else
-               /* Not valid hex */
-               return -1;
-
-       return offset;
-}
-
-
-/**
  * Create the components of a NetSurf URL object for a section of a URL string
  *
  * \param url_s                URL string
@@ -716,7 +677,7 @@ static nserror nsurl__create_from_section(const char * 
const url_s,
                        /* Might be an escaped character needing unescaped */
 
                        /* Find which character which was escaped */
-                       ascii_offset = nsurl__get_ascii_offset(*(pos + 1),
+                       ascii_offset = ascii_hex_to_value_2_chars(*(pos + 1),
                                        *(pos + 2));
 
                        if (ascii_offset < 0) {


-- 
NetSurf Browser

_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org

Reply via email to