Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.3.4

Bug #717 Code Incorrectly Decrypts 'Young'
Submitted: 2004-02-09 13:19 UTC Modified: 2004-02-18 04:58 UTC
From: crocha at polychrome dot org Assigned: mikedransfield
Status: Closed Package: HTML_Crypt
PHP Version: 4.3.3 OS: Redhat Linux
Roadmaps: (Not assigned)    
Subscription  


 [2004-02-09 13:19 UTC] crocha at polychrome dot org
Description: ------------ When the string 'Young' (with a capital Y only) is part of the string to be encrypted, JavaScript outputs 'ung' instead. This bug has been verified on the following browsers: Internet Explorer 6.0 Windows Mozilla 1.5 Windows Mozilla 1.2.1 Linux PHP Configure Commands Follow: './configure' 'i386-redhat-linux' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--prefix=/usr' '--cache-file=../config.cache' '--with-config-file-path=/etc' '--with-config-file-scan-dir=/etc/php.d' '--enable-force-cgi-redirect' '--disable-debug' '--enable-pic' '--disable-rpath' '--enable-inline-optimization' '--with-bz2' '--with-db3' '--with-curl' '--with-pear' '--with-dom=/usr' '--with-exec-dir=/usr/bin' '--with-freetype-dir=/usr' '--with-png-dir=/usr' '--with-gd' '--enable-gd-native-ttf' '--with-ttf' '--with-gdbm' '--with-gettext' '--with-ncurses' '--with-gmp' '--with-iconv' '--with-jpeg-dir=/usr' '--with-openssl' '--with-png' '--with-pspell' '--with-regex=system' '--with-xml' '--with-expat-dir=/usr' '--with-pcre=/usr' '--with-zlib' '--with-layout=GNU' '--enable-bcmath' '--enable-exif' '--enable-ftp' '--enable-magic-quotes' '--enable-safe-mode' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-discard-path' '--enable-track-vars' '--enable-trans-sid' '--enable-yp' '--enable-wddx' '--without-oci8' '--with-pear=/usr/share/pear' '--with-imap=shared' '--with-imap-ssl' '--with-kerberos' '--with-ldap=shared' '--with-mysql=shared,/usr' '--with-pgsql' '--with-snmp=shared,/usr' '--with-snmp=shared' '--enable-ucd-snmp-hack' '--with-unixODBC=shared' '--enable-memory-limit' '--enable-bcmath' '--enable-shmop' '--enable-versioning' '--enable-calendar' '--enable-dbx' '--enable-dio' '--enable-mcal' '--enable-mbstring' '--enable-mbstr-enc-trans' '--enable-mbregex' '--with-apxs=/usr/sbin/apxs' Reproduce code: --------------- <?php $c = new HTML_crypt('Young'); $c->output(); // Outputs 'ung' ?> <?php $c = new HTML_crypt('young'); $c->output(); // Outputs 'young' ?> <?php $c = new HTML_crypt('Hello, Youngster'); $c->output(); // Outputs 'Hello, ungster' ?> Actual result: -------------- Javascript output follows: <script language="JavaScript" type="text/JavaScript">var a,s,n;function f5c528387a02ae4c89272484269b8f611(s){r='';for(i=0;i<s.length;i++){n=s.charCodeAt(i);if(n>=8364){n=128;}r+=String.fromCharCode(n-3);}return r;}a='\rxqj';document.write (f5c528387a02ae4c89272484269b8f611(a));</script>

Comments

 [2004-02-14 09:37 UTC] mike
This should fix it: /** * Encrypts the text * * @access private */ function cryptText(){ $enc_string = ""; $length = strlen($this->text); for ($i=0;$i<$length;$i++) { $current_chr = substr($this->text, $i, 1); $inter = ord($current_chr)+$this->offset; $enc_char = chr($inter); $enc_string .= ($enc_char == '\\' ? '\\\\' : $enc_char); } $this->cryptString = $enc_string; } Mike
 [2004-02-18 04:58 UTC] mike
Thank you for your bug report. This issue has already been fixed in the latest released version of the package, which you can download at http://pear.php.net/packages.php