Author: rmeggins
Update of /cvs/dirsec/adminutil/include/libadminutil
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv3272/adminutil/include/libadminutil
Modified Files:
admutil.h
Log Message:
Resolves: bug 462411
Bug Description: certificate request wizard returns an error
Reviewed by: nkinder (Thanks!)
Fix Description: This was broken as part of the fix for the XSS issues. To fix that, in
order to make sure we never displayed any string that contained unescaped HTML entities,
we just go ahead and escape everything when we read the values from the CGI GET or POST
arguments. For this particular bug, this meant the cert CGI was getting a DN like this:
CN="ldap.example.com" instead of CN="ldap.example.com". The
solution is to add some functions to adminutil (stolen from dsgw) that can be used to
escape/unescape HTML entities. We have to be careful never to display unescaped strings -
in this particular case, the DN is never printed.
Platforms tested: RHEL5
Flag Day: yes - will require new adminutil, adminserver
Doc impact: no
Index: admutil.h
===================================================================
RCS file: /cvs/dirsec/adminutil/include/libadminutil/admutil.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- admutil.h 27 Aug 2008 20:05:58 -0000 1.9
+++ admutil.h 3 Dec 2008 17:31:26 -0000 1.10
@@ -424,6 +424,30 @@
#define WORD_WRAP_WIDTH 80
PR_IMPLEMENT(char) *alert_wrd_wrap(char *str, int width, char *linefeed);
+/*
+ * If the UTF8 string "s" contains any HTML special characters, make a
+ * duplicate where the appropriate HTML "entities" have been substituted
+ * for the special chars. For example, "<mcs(a)ace.com>" will be
translated
+ * to "&lt;mcs(a)ace.com&gt;".
+ *
+ * If "s" does not contain any special characters, it is returned and
+ * *madecopyp is set to 0.
+ * Otherwise a malloc'd string is returned and *madecopyp is set to 1.
+ */
+PR_IMPLEMENT(char *) strdup_escape_entities(char *s, int *madecopyp);
+
+/* this will convert a string with escaped entities ("&")
+ back to the original unescaped string ("&")
+ This is necessary for converting URLs and other values which would normally
+ have entities in them (e.g. search?context=foo&dn=bar)
+ for use in javascript (e.g. window.href = 'search?context=foo&dn=bar')
+ since javascript must use the unescaped version
+ This converts the string in place since the entities "&"
+ take up much more room than the single character represented
+ If you need to work on a copy then make a copy with strdup first.
+*/
+PR_IMPLEMENT(void) unescape_entities(char *s);
+
/* Get internal variable info data structure */
/* This is hack, should be removed later - YJH */
/* form_post.c */
Show replies by date