cvs: php3 / ChangeLog /functions basic_functions.c html.c html.h
| From: | Rasmus Lerdorf | Date: | Tue, 12 Sep 2000 17:23:30 +0000 |
| Subject: | cvs: php3 / ChangeLog /functions basic_functions.c html.c html.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-1732@lists.php.net to get a copy of this message | ||
rasmus Tue Sep 12 10:23:30 2000 EDT
Modified files:
/php3 ChangeLog
/php3/functions basic_functions.c html.c html.h
Log:
Clean up htmlspecialchars/htmlentities inconsistencies
Index: php3/ChangeLog
diff -u php3/ChangeLog:1.846 php3/ChangeLog:1.847
--- php3/ChangeLog:1.846 Sun Aug 6 17:09:54 2000
+++ php3/ChangeLog Tue Sep 12 10:23:30 2000
@@ -2,6 +2,7 @@
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?, 200x, Version 3.0.17
+- Clean up htmlspecialchars/htmlentities inconsistencies (Rasmus)
- Add optional charset parameter to sybase_[p]connect (alf@alpha.ulatina.ac.cr)
- Fixed incorrect handling of 0-precision strings (e.g., %4.0s)
in printf (Ken Coar)
Index: php3/functions/basic_functions.c
diff -u php3/functions/basic_functions.c:1.290 php3/functions/basic_functions.c:1.291
--- php3/functions/basic_functions.c:1.290 Sat Sep 9 14:05:45 2000
+++ php3/functions/basic_functions.c Tue Sep 12 10:23:30 2000
@@ -28,7 +28,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: basic_functions.c,v 1.290 2000/09/09 21:05:45 zeev Exp $ */
+/* $Id: basic_functions.c,v 1.291 2000/09/12 17:23:30 rasmus Exp $ */
#include "php.h"
#include "modules.h"
#include "internal_functions.h"
@@ -406,6 +406,10 @@
REGISTER_LONG_CONSTANT("EXTR_SKIP", EXTR_SKIP, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("EXTR_PREFIX_SAME", EXTR_PREFIX_SAME, CONST_CS |
CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("EXTR_PREFIX_ALL", EXTR_PREFIX_ALL, CONST_CS | CONST_PERSISTENT);
+
+ REGISTER_LONG_CONSTANT("ENT_COMPAT", ENT_COMPAT, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("ENT_QUOTES", ENT_QUOTES, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("ENT_NOQUOTES", ENT_NOQUOTES, CONST_CS | CONST_PERSISTENT);
_php3_hash_init(&sm_protected_env_vars, 5, NULL, NULL, 1);
Index: php3/functions/html.c
diff -u php3/functions/html.c:1.36 php3/functions/html.c:1.37
--- php3/functions/html.c:1.36 Tue Jul 25 03:18:27 2000
+++ php3/functions/html.c Tue Sep 12 10:23:30 2000
@@ -28,7 +28,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: html.c,v 1.36 2000/07/25 10:18:27 hholzgra Exp $ */
+/* $Id: html.c,v 1.37 2000/09/12 17:23:30 rasmus Exp $ */
#include "php.h"
#include "internal_functions.h"
@@ -65,7 +65,7 @@
#define ASC(ch) os_toascii[(unsigned char)ch]
#endif /* CHARSET_EBCDIC */
-PHPAPI char * _php3_htmlentities(char *s, int i, int all)
+PHPAPI char * _php3_htmlentities(char *s, int i, int all, int quote_style)
{
int len, maxlen;
unsigned char *old;
@@ -85,10 +85,10 @@
if ('&' == *old) {
memcpy (new + len, "&", 5);
len += 5;
- } else if ('"' == *old) {
+ } else if ('"' == *old && !(quote_style&ENT_NOQUOTES)) {
memcpy (new + len, """, 6);
len += 6;
- } else if (39 == *old) {
+ } else if (39 == *old && (quote_style&ENT_QUOTES)) {
/* single quote (') */
memcpy (new + len, "'",6);
len += 6;
@@ -114,22 +114,31 @@
static void _htmlentities(INTERNAL_FUNCTION_PARAMETERS, int all)
{
- pval *arg;
+ pval *arg, *quotes;
char *new;
+ int argc, quote_style;
TLS_VARS;
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
+ argc = ARG_COUNT(ht);
+
+ if ((argc == 1 && getParameters(ht, 1, &arg) == FAILURE) ||
+ (argc == 2 && getParameters(ht, 2, &arg, "es) == FAILURE) ||
+ argc < 1 || argc > 2) {
WRONG_PARAM_COUNT;
}
convert_to_string(arg);
-
- new = _php3_htmlentities(arg->value.str.val, arg->value.str.len, all);
+ if(argc==2) {
+ convert_to_long(quotes);
+ quote_style = quotes->value.lval;
+ } else quote_style = ENT_COMPAT;
+
+ new = _php3_htmlentities(arg->value.str.val, arg->value.str.len, all, quote_style);
RETVAL_STRINGL(new,strlen(new),0);
}
-/* {{{ proto string htmlspecialchars(string string)
+/* {{{ proto string htmlspecialchars(string string [, int quote_style])
Convert special characters to HTML entities */
void php3_htmlspecialchars(INTERNAL_FUNCTION_PARAMETERS)
{
@@ -138,7 +147,7 @@
}
/* }}} */
-/* {{{ proto string htmlentities(string string)
+/* {{{ proto string htmlentities(string string [, int quote_style])
Convert all applicable characters to HTML entities */
void php3_htmlentities(INTERNAL_FUNCTION_PARAMETERS)
{
Index: php3/functions/html.h
diff -u php3/functions/html.h:1.11 php3/functions/html.h:1.12
--- php3/functions/html.h:1.11 Fri Dec 31 20:44:09 1999
+++ php3/functions/html.h Tue Sep 12 10:23:30 2000
@@ -27,14 +27,18 @@
+----------------------------------------------------------------------+
*/
-/* $Id: html.h,v 1.11 2000/01/01 04:44:09 sas Exp $ */
+/* $Id: html.h,v 1.12 2000/09/12 17:23:30 rasmus Exp $ */
#ifndef _HTML_H
#define _HTML_H
+#define ENT_COMPAT 1
+#define ENT_QUOTES 2
+#define ENT_NOQUOTES 4
+
extern void php3_htmlspecialchars(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_htmlentities(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_gamma_correct_tag(INTERNAL_FUNCTION_PARAMETERS);
-PHPAPI char * _php3_htmlentities(char *s, int i, int all);
+PHPAPI char * _php3_htmlentities(char *s, int i, int all, int quote_style);
#endif /* _HTML_H */