geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jboy...@apache.org
Subject svn commit: r149312 - in geronimo/trunk/specs/activation/src: java/javax/activation/MailcapCommandMap.java test/javax/activation/MailcapCommandMapTest.java
Date Mon, 31 Jan 2005 22:49:19 GMT
Author: jboynes
Date: Mon Jan 31 14:49:17 2005
New Revision: 149312

URL: http://svn.apache.org/viewcvs?view=rev&rev=149312
Log:
strip parameters from mimeType when looking up commands

Modified:
    geronimo/trunk/specs/activation/src/java/javax/activation/MailcapCommandMap.java
    geronimo/trunk/specs/activation/src/test/javax/activation/MailcapCommandMapTest.java

Modified: geronimo/trunk/specs/activation/src/java/javax/activation/MailcapCommandMap.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/specs/activation/src/java/javax/activation/MailcapCommandMap.java?view=diff&r1=149311&r2=149312
==============================================================================
--- geronimo/trunk/specs/activation/src/java/javax/activation/MailcapCommandMap.java (original)
+++ geronimo/trunk/specs/activation/src/java/javax/activation/MailcapCommandMap.java Mon Jan
31 14:49:17 2005
@@ -271,12 +271,18 @@
     }
 
     public synchronized CommandInfo getCommand(String mimeType, String cmdName) {
+        // strip any parameters from the supplied mimeType
+        int i = mimeType.indexOf(';');
+        if (i != -1) {
+            mimeType = mimeType.substring(0, i).trim();
+        }
+
         // search for an exact match
         Map commands = (Map) preferredCommands.get(mimeType.toLowerCase());
         if(commands != null) {
             return (CommandInfo) commands.get(cmdName.toLowerCase());
         }
-        int i = mimeType.indexOf('/');
+        i = mimeType.indexOf('/');
         if (i == -1) {
             mimeType = mimeType + "/*";
         } else {

Modified: geronimo/trunk/specs/activation/src/test/javax/activation/MailcapCommandMapTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/specs/activation/src/test/javax/activation/MailcapCommandMapTest.java?view=diff&r1=149311&r2=149312
==============================================================================
--- geronimo/trunk/specs/activation/src/test/javax/activation/MailcapCommandMapTest.java (original)
+++ geronimo/trunk/specs/activation/src/test/javax/activation/MailcapCommandMapTest.java Mon
Jan 31 14:49:17 2005
@@ -71,6 +71,13 @@
         assertEquals("Star", info.getCommandClass());
     }
 
+    public void testParameterizedMimeType() {
+        map.addMailcap("foo/bar ;; x-java-view=Bar");
+        CommandInfo info = map.getCommand("foo/bar ; type=\"text/plain\"", "view");
+        assertEquals("view", info.getCommandName());
+        assertEquals("Bar", info.getCommandClass());
+    }
+
     protected void setUp() throws Exception {
         super.setUp();
         map = new MailcapCommandMap();



Mime
View raw message