Author: jsmeix Date: Fri Dec 11 18:16:29 2009 New Revision: 60085 URL: http://svn.opensuse.org/viewcvs/yast?rev=60085&view=rev Log: Added URIpercentDecoding function in connectionwizard.ycp which does the opposite of the URIpercentEncoding function and is used to un-do percent encoding for the values which are used for various test_remote_* scripts which fixes hopefully this bug. If some test_remote_* scripts work better with percent encoded values, it is very simple now to just remove the URIpercentDecoding call for the particular values in the testQueue function in connectionwizard.ycp. Modified: trunk/printer/src/Printer.ycp trunk/printer/src/connectionwizard.ycp trunk/printer/src/printingvianetwork.ycp Modified: trunk/printer/src/Printer.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/Printer.ycp?rev=60085&r1=60084&r2=60085&view=diff ============================================================================== --- trunk/printer/src/Printer.ycp (original) +++ trunk/printer/src/Printer.ycp Fri Dec 11 18:16:29 2009 @@ -781,7 +781,8 @@ if( size( words ) > 0 ) { boolean words_start_with_known_manufacturer = false; foreach( string known_manufacturer, - known_manufacturers, + // The specifically added manufacturer "Raw" is needed for a smooth setup of a "Raw Queue": + add( known_manufacturers, "Raw" ), { if( tolower( words[0]:"" ) == tolower( known_manufacturer ) ) { words_start_with_known_manufacturer = true; break; @@ -927,7 +928,8 @@ // is actually a known manufacturer name: boolean words_start_with_known_manufacturer = false; foreach( string known_manufacturer, - known_manufacturers, + // The specifically added manufacturer "Raw" is needed for a smooth setup of a "Raw Queue": + add( known_manufacturers, "Raw" ), { if( tolower( words[0]:"" ) == tolower( known_manufacturer ) ) { words_start_with_known_manufacturer = true; words[0] = "^" + words[0]:""; Modified: trunk/printer/src/connectionwizard.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/connectionwizard.ycp?rev=60085&r1=60084&r2=60085&view=diff ============================================================================== --- trunk/printer/src/connectionwizard.ycp (original) +++ trunk/printer/src/connectionwizard.ycp Fri Dec 11 18:16:29 2009 @@ -43,9 +43,34 @@ string connection_uri=""; string connection_model=""; +// Map of reserved URI characters ! # $ % & ' ( ) * + , / : ; = ? @ [ ] +// plus the space character and their matching percent encoding +// where each percent encoding must be exactly three characters +// and uppercase letters, otherwise URIpercentDecoding will not work: +map< string, string > uri_percent_encodings = $[ " ":"%20", + "!":"%21", + "#":"%23", + "$":"%24", + "&":"%26", + "'":"%27", + "(":"%28", + ")":"%29", + "*":"%2A", + "+":"%2B", + ",":"%2C", + "/":"%2F", + ":":"%3A", + ";":"%3B", + "=":"%3D", + "?":"%3F", + "@":"%40", + "[":"%5B", + "]":"%5D" + ]; + string URIpercentEncoding( string input ) { // Replace space and each reserved character ! # $ % & ' ( ) * + , / : ; = ? @ [ ] - // in a value of an URI with its percent encoding, see + // in a value (component) of an URI with its percent encoding, see // https://bugzilla.novell.com/show_bug.cgi?id=512549 // This function is only meant as "some kind of automated fix" // when the user entered URI values but forgot to do percent encoding. @@ -64,32 +89,45 @@ string output = input; foreach( string reserved_character, string percent_encoding, - $[ " ":"%20", - "!":"%21", - "#":"%23", - "$":"%24", - "&":"%26", - "'":"%27", - "(":"%28", - ")":"%29", - "*":"%2A", - "+":"%2B", - ",":"%2C", - "/":"%2F", - ":":"%3A", - ";":"%3B", - "=":"%3D", - "?":"%3F", - "@":"%40", - "[":"%5B", - "]":"%5D" - ], + uri_percent_encodings, { output = mergestring( splitstring( output, reserved_character ), percent_encoding ); } ); return output; } +string URIpercentDecoding( string input ) +{ // The opposite of the above URIpercentEncoding function so that + // URIpercentDecoding( URIpercentEncoding ( input ) ) == input + string output = input; + foreach( string reserved_character, + string percent_encoding, + uri_percent_encodings, + { // Assume output = "Foo%2aBar%2aBaz" + integer position = search( output, percent_encoding ); + // position = nil = search( "Foo%2ABar%2ABaz", "%2A" ) + if( nil == position ) + { position = search( output, tolower( percent_encoding ) ); + // position = 3 = search( "Foo%2aBar%2aBaz", "%2a" ) + } + while( position != nil ) + { // Each percent encoding is exactly three characters so that + // the first position characters are those up to the current percent encoding + // and at position + 3 the rest after the current percent encoding starts: + output = substring( output, 0, position ) + reserved_character + substring( output, position + 3 ); + // output = "Foo*Bar%2aBaz" = "Foo" + "*" + "Bar%2aBaz" + position = search( output, percent_encoding ); + // position = nil = search( "Foo*Bar%2aBaz", "%2A" ) + if( nil == position ) + { position = search( output, tolower( percent_encoding ) ); + // position = 7 = search( "Foo*Bar%2aBaz", "%2a" ) + } + } + } + ); + return output; +} + string getCurrentDeviceURI() { if( "" != Printer::connections[Printer::selected_connections_index,"uri"]:"") { return Printer::connections[Printer::selected_connections_index,"uri"]:""; @@ -2444,8 +2482,8 @@ string password = ""; switch(selected) { case(`tcp): - host = (string)UI::QueryWidget( `hostname, `Value ); - port = (string)UI::QueryWidget( `port_or_queue, `Value ); + host = URIpercentDecoding( (string)UI::QueryWidget( `hostname, `Value ) ); + port = URIpercentDecoding( (string)UI::QueryWidget( `port_or_queue, `Value ) ); test_command = sformat( "%1test_remote_socket \"%2\" \"%3\" %4", Printerlib::yast_bin_dir, host, @@ -2467,8 +2505,8 @@ break; case(`lpd): case(`lpr): - host = (string)UI::QueryWidget( `hostname, `Value ); - queue = (string)UI::QueryWidget( `port_or_queue, `Value ); + host = URIpercentDecoding( (string)UI::QueryWidget( `hostname, `Value ) ); + queue = URIpercentDecoding( (string)UI::QueryWidget( `port_or_queue, `Value ) ); port = "515"; test_command = sformat( "%1test_remote_lpd \"%2\" \"%3\" %4", Printerlib::yast_bin_dir, @@ -2490,8 +2528,8 @@ } break; case(`cups): - host = (string)UI::QueryWidget( `hostname, `Value ); - queue = (string)UI::QueryWidget( `queue, `Value ); + host = URIpercentDecoding( (string)UI::QueryWidget( `hostname, `Value ) ); + queue = URIpercentDecoding( (string)UI::QueryWidget( `queue, `Value ) ); test_command = sformat( "%1test_remote_ipp \"%2\" \"%3\" %4", Printerlib::yast_bin_dir, host, @@ -2512,11 +2550,11 @@ } break; case(`smb): - host = (string)UI::QueryWidget( `hostname, `Value ); - queue = (string)UI::QueryWidget( `printer, `Value ); - workgroup = (string)UI::QueryWidget( `domain, `Value ); - user = (string)UI::QueryWidget( `user, `Value ); - password = (string)UI::QueryWidget( `pass, `Value ); + host = URIpercentDecoding( (string)UI::QueryWidget( `hostname, `Value ) ); + queue = URIpercentDecoding( (string)UI::QueryWidget( `printer, `Value ) ); + workgroup = URIpercentDecoding( (string)UI::QueryWidget( `domain, `Value ) ); + user = URIpercentDecoding( (string)UI::QueryWidget( `user, `Value ) ); + password = URIpercentDecoding( (string)UI::QueryWidget( `pass, `Value ) ); test_command = sformat( "%1test_remote_smb \"%2\" \"%3\" \"%4\" \"%5\" \"%6\" %7", Printerlib::yast_bin_dir, workgroup, @@ -2540,10 +2578,10 @@ } break; case(`ipx): - host = (string)UI::QueryWidget( `hostname, `Value ); - queue = (string)UI::QueryWidget( `queue, `Value ); - user = (string)UI::QueryWidget( `user, `Value ); - password = (string)UI::QueryWidget( `pass, `Value ); + host = URIpercentDecoding( (string)UI::QueryWidget( `hostname, `Value ) ); + queue = URIpercentDecoding( (string)UI::QueryWidget( `queue, `Value ) ); + user = URIpercentDecoding( (string)UI::QueryWidget( `user, `Value ) ); + password = URIpercentDecoding( (string)UI::QueryWidget( `pass, `Value ) ); test_command = sformat( "%1test_remote_novell \"%2\" \"%3\" \"%4\" \"%5\" %6", Printerlib::yast_bin_dir, host, Modified: trunk/printer/src/printingvianetwork.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/printingvianetwork.ycp?rev=60085&r1=60084&r2=60085&view=diff ============================================================================== --- trunk/printer/src/printingvianetwork.ycp (original) +++ trunk/printer/src/printingvianetwork.ycp Fri Dec 11 18:16:29 2009 @@ -1063,7 +1063,15 @@ return `printing_via_network_next; } if( `connection_wizard == event["ID"]:nil ) - { return `printing_via_network_connection_wizard; + { // Invalidate Printer::selected_connections_index and Printer::selected_queues_index + // so that the getCurrentDeviceURI function in connectionwizard.ycp fails + // to avoid that the URI of whatever preselected queue in the Overview dialog + // becomes preselected in the Connection Wizard which should actually + // start without any preselection because a new queue is to be set up + // when the Connection Wizard is called from the Print via Network dialog: + Printer::selected_connections_index = -1; + Printer::selected_queues_index = -1; + return `printing_via_network_connection_wizard; } if( `test_client_conf_server == event["ID"]:nil ) { string current_client_conf_input_value = (string)UI::QueryWidget( `id(`client_conf_input), `Value ); -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org