View the DQSD CVS repository here:
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/dqsd/

Update of /cvsroot/dqsd/dqsd/src/DQSDSearchWiz
In directory usw-pr-cvs1:/tmp/cvs-serv29792/src/DQSDSearchWiz

Modified Files:
        ChangeLog.txt DQSDSearchWiz.dsp DQSDWizardDlg.cpp 
        DQSDWizardDlg.h StdAfx.h 
Log Message:
* Form element names with weird characters ([^_a-zA-Z]) are now referenced correctly.
* Escape <,>,& characters in user text and HTML text


Index: ChangeLog.txt
===================================================================
RCS file: /cvsroot/dqsd/dqsd/src/DQSDSearchWiz/ChangeLog.txt,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ChangeLog.txt       8 Aug 2002 07:42:04 -0000       1.1
--- ChangeLog.txt       8 Aug 2002 21:25:48 -0000       1.2
***************
*** 1,2 ****
--- 1,8 ----
+ Version 0.4 (beta) - 08-Aug-2002
+ 
+ * Form element names with weird characters ([^_a-zA-Z])
+   are now referenced correctly.
+ * Escape <,>,& characters in user text and HTML text
+ 
  Version 0.3 (beta) - 08-Aug-2002
  

Index: DQSDSearchWiz.dsp
===================================================================
RCS file: /cvsroot/dqsd/dqsd/src/DQSDSearchWiz/DQSDSearchWiz.dsp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** DQSDSearchWiz.dsp   8 Aug 2002 07:37:34 -0000       1.5
--- DQSDSearchWiz.dsp   8 Aug 2002 21:25:48 -0000       1.6
***************
*** 200,203 ****
--- 200,207 ----
  # End Source File
  # End Group
+ # Begin Source File
+ 
+ SOURCE=.\ChangeLog.txt
+ # End Source File
  # End Target
  # End Project

Index: DQSDWizardDlg.cpp
===================================================================
RCS file: /cvsroot/dqsd/dqsd/src/DQSDSearchWiz/DQSDWizardDlg.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** DQSDWizardDlg.cpp   8 Aug 2002 07:37:34 -0000       1.14
--- DQSDWizardDlg.cpp   8 Aug 2002 21:25:48 -0000       1.15
***************
*** 7,10 ****
--- 7,37 ----
  #include "ModulVer.h"
  
+ 
+ void srch_repl( string& s, const string& to_find, const string& repl_with ) 
+ {
+       if ( s.find(to_find, 0) == string::npos )
+               return;
+ 
+       string result;
+       string::size_type pos = 0;
+       
+       while ( true ) 
+       {
+               string::size_type next = s.find( to_find, pos );
+               result.append( s, pos, next - pos );
+               if( next != string::npos ) 
+               {
+                       result.append( repl_with );
+                       pos = next + to_find.size();
+               } 
+               else 
+               {   
+                       break;  // exit loop
+               }
+       } 
+       s.swap( result );
+ }
+ 
+ 
  /////////////////////////////////////////////////////////////////////////////
  // CDQSDWizardDlg
***************
*** 309,321 ****
  
        CWindow( GetDlgItem( IDC_SearchTitle ) ).GetWindowText( &bstr );
!       strSearchFile += _T("\r\n  <name>") + string( W2T( bstr ) ) + _T("</name>");
        ::SysFreeString( bstr );
  
        CWindow( GetDlgItem( IDC_Category ) ).GetWindowText( &bstr );
!       strSearchFile += _T("\r\n  <category>") + string( W2T( bstr ) ) + 
_T("</category>");
        ::SysFreeString( bstr );
        
        CWindow( GetDlgItem( IDC_Contributor ) ).GetWindowText( &bstr );
!       strSearchFile += _T("\r\n  <contributor>") + string( W2T( bstr ) ) + 
_T("</contributor>");
        ::SysFreeString( bstr );
  
--- 336,348 ----
  
        CWindow( GetDlgItem( IDC_SearchTitle ) ).GetWindowText( &bstr );
!       strSearchFile += _T("\r\n  <name>") + EscapeXML( string( W2T( bstr ) ) ) + 
_T("</name>");
        ::SysFreeString( bstr );
  
        CWindow( GetDlgItem( IDC_Category ) ).GetWindowText( &bstr );
!       strSearchFile += _T("\r\n  <category>") + EscapeXML( string( W2T( bstr ) ) ) + 
_T("</category>");
        ::SysFreeString( bstr );
        
        CWindow( GetDlgItem( IDC_Contributor ) ).GetWindowText( &bstr );
!       strSearchFile += _T("\r\n  <contributor>") + EscapeXML( string( W2T( bstr ) ) 
) + _T("</contributor>");
        ::SysFreeString( bstr );
  
***************
*** 332,336 ****
        strSearchFile += _T("\r\n  <description>");
        if ( _tcslen( W2T( bstr ) ) )
!               strSearchFile += _T("\r\n  ") + string( W2T( bstr ) );
        strSearchFile += _T("\r\n  </description>");
        ::SysFreeString( bstr );
--- 359,363 ----
        strSearchFile += _T("\r\n  <description>");
        if ( _tcslen( W2T( bstr ) ) )
!               strSearchFile += _T("\r\n  ") + EscapeXML( string( W2T( bstr ) ) );
        strSearchFile += _T("\r\n  </description>");
        ::SysFreeString( bstr );
***************
*** 503,508 ****
--- 530,537 ----
  
                                        _variant_t varInputName;
+                                       string strInputName;
                                        if ( SUCCEEDED( spElement->getAttribute( 
_bstr_t( _T("name") ), 0, &varInputName ) ) && varInputName.bstrVal )
                                        {
+                                               strInputName = W2T( 
+varInputName.bstrVal );
  
                                                // Ignore INPUT type=submit
***************
*** 521,525 ****
                                                }
  
!                                               strFormXML += _T("\r\n    <input 
type=\"hidden\" name=\"") + string( W2T( varInputName.bstrVal ) ) + _T("\"");
  
                                                // Stick the value of the field in as 
well for two reasons... some hidden fields are required 
--- 550,554 ----
                                                }
  
!                                               strFormXML += _T("\r\n    <input 
type=\"hidden\" name=\"") + strInputName + _T("\"");
  
                                                // Stick the value of the field in as 
well for two reasons... some hidden fields are required 
***************
*** 529,533 ****
                                                if ( SUCCEEDED( 
spElement->getAttribute( _bstr_t( _T("value") ), 0, &varInputValue ) ) && 
varInputValue.bstrVal )
                                                {
!                                                       strFormXML += _T(" value=\"") 
+ string( W2T( varInputValue.bstrVal ) ) + _T("\"");
                                                }
                                                else
--- 558,562 ----
                                                if ( SUCCEEDED( 
spElement->getAttribute( _bstr_t( _T("value") ), 0, &varInputValue ) ) && 
varInputValue.bstrVal )
                                                {
!                                                       strFormXML += _T(" value=\"") 
+ EscapeXML( string( W2T( varInputValue.bstrVal ) ) ) + _T("\"");
                                                }
                                                else
***************
*** 538,541 ****
--- 567,579 ----
                                                strFormXML += _T("/>");
  
+                                               // If there are any non-alpha 
+characters in the INPUT field name, the use different notation in the script
+                                               string strScriptInputName = _T(".") + 
+strInputName + _T(".value");
+                                               if ( ( strInputName.find_first_not_of( 
+_T("_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0 ) != string::npos ) ||
+                                                        ( !_tcsicmp( 
+strInputName.c_str(), _T("target") ) ) ||
+                                                        ( !_tcsicmp( 
+strInputName.c_str(), _T("submit") ) ) )
+                                               {
+                                                       strScriptInputName = _T("[\"") 
++ strInputName + _T("\"].value");
+                                               }
+ 
                                                if ( bActiveElement )
                                                {
***************
*** 544,552 ****
                                                                                       
          "\r\n      // this field was the active element when the search file was 
generated."
                                                                                       
          "\r\n      // Change this to args.q if the search string is parsed with 
parseArgs."
!                                                                                      
          "\r\n      document.") + strFormName + _T(".") + string( W2T( 
varInputName.bstrVal ) ) + _T(".value = q;");
                                                }
                                                else
                                                {
!                                                       rstrFormScript += _T("\r\n     
 //document.") + strFormName + _T(".") + string( W2T( varInputName.bstrVal ) ) + 
_T(".value = \"\";");
                                                }
  
--- 582,590 ----
                                                                                       
          "\r\n      // this field was the active element when the search file was 
generated."
                                                                                       
          "\r\n      // Change this to args.q if the search string is parsed with 
parseArgs."
!                                                                                      
          "\r\n      document.") + strFormName + strScriptInputName + _T(" = q;");
                                                }
                                                else
                                                {
!                                                       rstrFormScript += _T("\r\n     
 //document.") + strFormName + strScriptInputName + _T(" = \"\";");
                                                }
  
***************
*** 554,558 ****
                                                {
                                                        strFormXML += _T("\r\n    
<COMMENT>  The input element above was a SELECT element with the following 
options...");
!                                                       strFormXML += _T("\r\n      
<select name=\"" + string( W2T( varInputName.bstrVal ) ) + "\">");
                                                        
                                                        CComQIPtr< IHTMLSelectElement 
> spSelect( spElement );
--- 592,596 ----
                                                {
                                                        strFormXML += _T("\r\n    
<COMMENT>  The input element above was a SELECT element with the following 
options...");
!                                                       strFormXML += _T("\r\n      
<select name=\"" + strInputName + "\">");
                                                        
                                                        CComQIPtr< IHTMLSelectElement 
> spSelect( spElement );
***************
*** 577,581 ****
                                                                        strFormXML += 
_T("\r\n        <option");
                                                                        if ( 
bstrOptionValue )
!                                                                               
strFormXML += _T(" value=\"") + string( W2T( bstrOptionValue ) ) + _T("\"");
                                                                        strFormXML += 
_T(">");
                                                                        strFormXML += 
EscapeXML( string( W2T( bstrOptionText ) ) ) + _T("</option>");
--- 615,619 ----
                                                                        strFormXML += 
_T("\r\n        <option");
                                                                        if ( 
bstrOptionValue )
!                                                                               
strFormXML += _T(" value=\"") + EscapeXML( string( W2T( bstrOptionValue ) ) ) + 
_T("\"");
                                                                        strFormXML += 
_T(">");
                                                                        strFormXML += 
EscapeXML( string( W2T( bstrOptionText ) ) ) + _T("</option>");
***************
*** 697,706 ****
  string CDQSDWizardDlg::EscapeXML( string& xml )
  {
!       string strEscapedXML = xml;
! 
!       // ??? Very quick hack to get rid of ampersands until we figure out a better 
way
!       replace( strEscapedXML.begin(), strEscapedXML.end(), _T('&'), _T('~') );
  
!       return strEscapedXML;
  }
  
--- 735,745 ----
  string CDQSDWizardDlg::EscapeXML( string& xml )
  {
!       srch_repl( xml, _T("&"), _T("&amp;") );
!       srch_repl( xml, _T("<"), _T("&lt;") );
!       srch_repl( xml, _T(">"), _T("&gt;") );
! //    srch_repl( xml, _T("'"), _T("&apos;") );
! //    srch_repl( xml, _T("\""), _T("&quot;") );
  
!       return xml;
  }
  

Index: DQSDWizardDlg.h
===================================================================
RCS file: /cvsroot/dqsd/dqsd/src/DQSDSearchWiz/DQSDWizardDlg.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** DQSDWizardDlg.h     7 Aug 2002 18:22:07 -0000       1.8
--- DQSDWizardDlg.h     8 Aug 2002 21:25:48 -0000       1.9
***************
*** 5,9 ****
  
  #include "resource.h"       // main symbols
- #include <atlhost.h>
  
  /////////////////////////////////////////////////////////////////////////////
--- 5,8 ----

Index: StdAfx.h
===================================================================
RCS file: /cvsroot/dqsd/dqsd/src/DQSDSearchWiz/StdAfx.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** StdAfx.h    7 Aug 2002 18:22:07 -0000       1.6
--- StdAfx.h    8 Aug 2002 21:25:49 -0000       1.7
***************
*** 29,32 ****
--- 29,34 ----
  #include <time.h>
  #include <atlhost.h>
+ #include <atlapp.h>
+ #include <atlctrls.h>
  
  #include <string>




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
DQSD-CVS mailing list
https://lists.sourceforge.net/lists/listinfo/dqsd-cvs
DQSD CVS repository:
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/dqsd/

Reply via email to