Index: /FCKeditor.Java/tags/2.4/LICENSE.txt
===================================================================
--- /FCKeditor.Java/tags/2.4/LICENSE.txt (revision 2194)
+++ /FCKeditor.Java/tags/2.4/LICENSE.txt (revision 2194)
@@ -0,0 +1,1247 @@
+FCKeditor - The text editor for Internet - http://www.fckeditor.net
+Copyright (C) 2003-2008 Frederico Caldeira Knabben
+
+Licensed under the terms of any of the following licenses at your
+choice:
+
+ - GNU General Public License Version 2 or later (the "GPL")
+ http://www.gnu.org/licenses/gpl.html
+ (See Appendix A)
+
+ - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ http://www.gnu.org/licenses/lgpl.html
+ (See Appendix B)
+
+ - Mozilla Public License Version 1.1 or later (the "MPL")
+ http://www.mozilla.org/MPL/MPL-1.1.html
+ (See Appendix C)
+
+You are not required to, but if you want to explicitly declare the
+license you have chosen to be bound to when using, reproducing,
+modifying and distributing this software, just include a text file
+titled "legal.txt" in your version of this software, indicating your
+license choice. In any case, your choice will not restrict any
+recipient of your version of this software to use, reproduce, modify
+and distribute this software under any of the above licenses.
+
+Appendix A: The GPL License
+===========================
+
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+
+Appendix B: The LGPL License
+============================
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+
+Appendix C: The MPL License
+===========================
+
+ MOZILLA PUBLIC LICENSE
+ Version 1.1
+
+ ---------------
+
+1. Definitions.
+
+ 1.0.1. "Commercial Use" means distribution or otherwise making the
+ Covered Code available to a third party.
+
+ 1.1. "Contributor" means each entity that creates or contributes to
+ the creation of Modifications.
+
+ 1.2. "Contributor Version" means the combination of the Original
+ Code, prior Modifications used by a Contributor, and the Modifications
+ made by that particular Contributor.
+
+ 1.3. "Covered Code" means the Original Code or Modifications or the
+ combination of the Original Code and Modifications, in each case
+ including portions thereof.
+
+ 1.4. "Electronic Distribution Mechanism" means a mechanism generally
+ accepted in the software development community for the electronic
+ transfer of data.
+
+ 1.5. "Executable" means Covered Code in any form other than Source
+ Code.
+
+ 1.6. "Initial Developer" means the individual or entity identified
+ as the Initial Developer in the Source Code notice required by Exhibit
+ A.
+
+ 1.7. "Larger Work" means a work which combines Covered Code or
+ portions thereof with code not governed by the terms of this License.
+
+ 1.8. "License" means this document.
+
+ 1.8.1. "Licensable" means having the right to grant, to the maximum
+ extent possible, whether at the time of the initial grant or
+ subsequently acquired, any and all of the rights conveyed herein.
+
+ 1.9. "Modifications" means any addition to or deletion from the
+ substance or structure of either the Original Code or any previous
+ Modifications. When Covered Code is released as a series of files, a
+ Modification is:
+ A. Any addition to or deletion from the contents of a file
+ containing Original Code or previous Modifications.
+
+ B. Any new file that contains any part of the Original Code or
+ previous Modifications.
+
+ 1.10. "Original Code" means Source Code of computer software code
+ which is described in the Source Code notice required by Exhibit A as
+ Original Code, and which, at the time of its release under this
+ License is not already Covered Code governed by this License.
+
+ 1.10.1. "Patent Claims" means any patent claim(s), now owned or
+ hereafter acquired, including without limitation, method, process,
+ and apparatus claims, in any patent Licensable by grantor.
+
+ 1.11. "Source Code" means the preferred form of the Covered Code for
+ making modifications to it, including all modules it contains, plus
+ any associated interface definition files, scripts used to control
+ compilation and installation of an Executable, or source code
+ differential comparisons against either the Original Code or another
+ well known, available Covered Code of the Contributor's choice. The
+ Source Code can be in a compressed or archival form, provided the
+ appropriate decompression or de-archiving software is widely available
+ for no charge.
+
+ 1.12. "You" (or "Your") means an individual or a legal entity
+ exercising rights under, and complying with all of the terms of, this
+ License or a future version of this License issued under Section 6.1.
+ For legal entities, "You" includes any entity which controls, is
+ controlled by, or is under common control with You. For purposes of
+ this definition, "control" means (a) the power, direct or indirect,
+ to cause the direction or management of such entity, whether by
+ contract or otherwise, or (b) ownership of more than fifty percent
+ (50%) of the outstanding shares or beneficial ownership of such
+ entity.
+
+2. Source Code License.
+
+ 2.1. The Initial Developer Grant.
+ The Initial Developer hereby grants You a world-wide, royalty-free,
+ non-exclusive license, subject to third party intellectual property
+ claims:
+ (a) under intellectual property rights (other than patent or
+ trademark) Licensable by Initial Developer to use, reproduce,
+ modify, display, perform, sublicense and distribute the Original
+ Code (or portions thereof) with or without Modifications, and/or
+ as part of a Larger Work; and
+
+ (b) under Patents Claims infringed by the making, using or
+ selling of Original Code, to make, have made, use, practice,
+ sell, and offer for sale, and/or otherwise dispose of the
+ Original Code (or portions thereof).
+
+ (c) the licenses granted in this Section 2.1(a) and (b) are
+ effective on the date Initial Developer first distributes
+ Original Code under the terms of this License.
+
+ (d) Notwithstanding Section 2.1(b) above, no patent license is
+ granted: 1) for code that You delete from the Original Code; 2)
+ separate from the Original Code; or 3) for infringements caused
+ by: i) the modification of the Original Code or ii) the
+ combination of the Original Code with other software or devices.
+
+ 2.2. Contributor Grant.
+ Subject to third party intellectual property claims, each Contributor
+ hereby grants You a world-wide, royalty-free, non-exclusive license
+
+ (a) under intellectual property rights (other than patent or
+ trademark) Licensable by Contributor, to use, reproduce, modify,
+ display, perform, sublicense and distribute the Modifications
+ created by such Contributor (or portions thereof) either on an
+ unmodified basis, with other Modifications, as Covered Code
+ and/or as part of a Larger Work; and
+
+ (b) under Patent Claims infringed by the making, using, or
+ selling of Modifications made by that Contributor either alone
+ and/or in combination with its Contributor Version (or portions
+ of such combination), to make, use, sell, offer for sale, have
+ made, and/or otherwise dispose of: 1) Modifications made by that
+ Contributor (or portions thereof); and 2) the combination of
+ Modifications made by that Contributor with its Contributor
+ Version (or portions of such combination).
+
+ (c) the licenses granted in Sections 2.2(a) and 2.2(b) are
+ effective on the date Contributor first makes Commercial Use of
+ the Covered Code.
+
+ (d) Notwithstanding Section 2.2(b) above, no patent license is
+ granted: 1) for any code that Contributor has deleted from the
+ Contributor Version; 2) separate from the Contributor Version;
+ 3) for infringements caused by: i) third party modifications of
+ Contributor Version or ii) the combination of Modifications made
+ by that Contributor with other software (except as part of the
+ Contributor Version) or other devices; or 4) under Patent Claims
+ infringed by Covered Code in the absence of Modifications made by
+ that Contributor.
+
+3. Distribution Obligations.
+
+ 3.1. Application of License.
+ The Modifications which You create or to which You contribute are
+ governed by the terms of this License, including without limitation
+ Section 2.2. The Source Code version of Covered Code may be
+ distributed only under the terms of this License or a future version
+ of this License released under Section 6.1, and You must include a
+ copy of this License with every copy of the Source Code You
+ distribute. You may not offer or impose any terms on any Source Code
+ version that alters or restricts the applicable version of this
+ License or the recipients' rights hereunder. However, You may include
+ an additional document offering the additional rights described in
+ Section 3.5.
+
+ 3.2. Availability of Source Code.
+ Any Modification which You create or to which You contribute must be
+ made available in Source Code form under the terms of this License
+ either on the same media as an Executable version or via an accepted
+ Electronic Distribution Mechanism to anyone to whom you made an
+ Executable version available; and if made available via Electronic
+ Distribution Mechanism, must remain available for at least twelve (12)
+ months after the date it initially became available, or at least six
+ (6) months after a subsequent version of that particular Modification
+ has been made available to such recipients. You are responsible for
+ ensuring that the Source Code version remains available even if the
+ Electronic Distribution Mechanism is maintained by a third party.
+
+ 3.3. Description of Modifications.
+ You must cause all Covered Code to which You contribute to contain a
+ file documenting the changes You made to create that Covered Code and
+ the date of any change. You must include a prominent statement that
+ the Modification is derived, directly or indirectly, from Original
+ Code provided by the Initial Developer and including the name of the
+ Initial Developer in (a) the Source Code, and (b) in any notice in an
+ Executable version or related documentation in which You describe the
+ origin or ownership of the Covered Code.
+
+ 3.4. Intellectual Property Matters
+ (a) Third Party Claims.
+ If Contributor has knowledge that a license under a third party's
+ intellectual property rights is required to exercise the rights
+ granted by such Contributor under Sections 2.1 or 2.2,
+ Contributor must include a text file with the Source Code
+ distribution titled "LEGAL" which describes the claim and the
+ party making the claim in sufficient detail that a recipient will
+ know whom to contact. If Contributor obtains such knowledge after
+ the Modification is made available as described in Section 3.2,
+ Contributor shall promptly modify the LEGAL file in all copies
+ Contributor makes available thereafter and shall take other steps
+ (such as notifying appropriate mailing lists or newsgroups)
+ reasonably calculated to inform those who received the Covered
+ Code that new knowledge has been obtained.
+
+ (b) Contributor APIs.
+ If Contributor's Modifications include an application programming
+ interface and Contributor has knowledge of patent licenses which
+ are reasonably necessary to implement that API, Contributor must
+ also include this information in the LEGAL file.
+
+ (c) Representations.
+ Contributor represents that, except as disclosed pursuant to
+ Section 3.4(a) above, Contributor believes that Contributor's
+ Modifications are Contributor's original creation(s) and/or
+ Contributor has sufficient rights to grant the rights conveyed by
+ this License.
+
+ 3.5. Required Notices.
+ You must duplicate the notice in Exhibit A in each file of the Source
+ Code. If it is not possible to put such notice in a particular Source
+ Code file due to its structure, then You must include such notice in a
+ location (such as a relevant directory) where a user would be likely
+ to look for such a notice. If You created one or more Modification(s)
+ You may add your name as a Contributor to the notice described in
+ Exhibit A. You must also duplicate this License in any documentation
+ for the Source Code where You describe recipients' rights or ownership
+ rights relating to Covered Code. You may choose to offer, and to
+ charge a fee for, warranty, support, indemnity or liability
+ obligations to one or more recipients of Covered Code. However, You
+ may do so only on Your own behalf, and not on behalf of the Initial
+ Developer or any Contributor. You must make it absolutely clear than
+ any such warranty, support, indemnity or liability obligation is
+ offered by You alone, and You hereby agree to indemnify the Initial
+ Developer and every Contributor for any liability incurred by the
+ Initial Developer or such Contributor as a result of warranty,
+ support, indemnity or liability terms You offer.
+
+ 3.6. Distribution of Executable Versions.
+ You may distribute Covered Code in Executable form only if the
+ requirements of Section 3.1-3.5 have been met for that Covered Code,
+ and if You include a notice stating that the Source Code version of
+ the Covered Code is available under the terms of this License,
+ including a description of how and where You have fulfilled the
+ obligations of Section 3.2. The notice must be conspicuously included
+ in any notice in an Executable version, related documentation or
+ collateral in which You describe recipients' rights relating to the
+ Covered Code. You may distribute the Executable version of Covered
+ Code or ownership rights under a license of Your choice, which may
+ contain terms different from this License, provided that You are in
+ compliance with the terms of this License and that the license for the
+ Executable version does not attempt to limit or alter the recipient's
+ rights in the Source Code version from the rights set forth in this
+ License. If You distribute the Executable version under a different
+ license You must make it absolutely clear that any terms which differ
+ from this License are offered by You alone, not by the Initial
+ Developer or any Contributor. You hereby agree to indemnify the
+ Initial Developer and every Contributor for any liability incurred by
+ the Initial Developer or such Contributor as a result of any such
+ terms You offer.
+
+ 3.7. Larger Works.
+ You may create a Larger Work by combining Covered Code with other code
+ not governed by the terms of this License and distribute the Larger
+ Work as a single product. In such a case, You must make sure the
+ requirements of this License are fulfilled for the Covered Code.
+
+4. Inability to Comply Due to Statute or Regulation.
+
+ If it is impossible for You to comply with any of the terms of this
+ License with respect to some or all of the Covered Code due to
+ statute, judicial order, or regulation then You must: (a) comply with
+ the terms of this License to the maximum extent possible; and (b)
+ describe the limitations and the code they affect. Such description
+ must be included in the LEGAL file described in Section 3.4 and must
+ be included with all distributions of the Source Code. Except to the
+ extent prohibited by statute or regulation, such description must be
+ sufficiently detailed for a recipient of ordinary skill to be able to
+ understand it.
+
+5. Application of this License.
+
+ This License applies to code to which the Initial Developer has
+ attached the notice in Exhibit A and to related Covered Code.
+
+6. Versions of the License.
+
+ 6.1. New Versions.
+ Netscape Communications Corporation ("Netscape") may publish revised
+ and/or new versions of the License from time to time. Each version
+ will be given a distinguishing version number.
+
+ 6.2. Effect of New Versions.
+ Once Covered Code has been published under a particular version of the
+ License, You may always continue to use it under the terms of that
+ version. You may also choose to use such Covered Code under the terms
+ of any subsequent version of the License published by Netscape. No one
+ other than Netscape has the right to modify the terms applicable to
+ Covered Code created under this License.
+
+ 6.3. Derivative Works.
+ If You create or use a modified version of this License (which you may
+ only do in order to apply it to code which is not already Covered Code
+ governed by this License), You must (a) rename Your license so that
+ the phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape",
+ "MPL", "NPL" or any confusingly similar phrase do not appear in your
+ license (except to note that your license differs from this License)
+ and (b) otherwise make it clear that Your version of the license
+ contains terms which differ from the Mozilla Public License and
+ Netscape Public License. (Filling in the name of the Initial
+ Developer, Original Code or Contributor in the notice described in
+ Exhibit A shall not of themselves be deemed to be modifications of
+ this License.)
+
+7. DISCLAIMER OF WARRANTY.
+
+ COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF
+ DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING.
+ THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE
+ IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT,
+ YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE
+ COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER
+ OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF
+ ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
+
+8. TERMINATION.
+
+ 8.1. This License and the rights granted hereunder will terminate
+ automatically if You fail to comply with terms herein and fail to cure
+ such breach within 30 days of becoming aware of the breach. All
+ sublicenses to the Covered Code which are properly granted shall
+ survive any termination of this License. Provisions which, by their
+ nature, must remain in effect beyond the termination of this License
+ shall survive.
+
+ 8.2. If You initiate litigation by asserting a patent infringement
+ claim (excluding declatory judgment actions) against Initial Developer
+ or a Contributor (the Initial Developer or Contributor against whom
+ You file such action is referred to as "Participant") alleging that:
+
+ (a) such Participant's Contributor Version directly or indirectly
+ infringes any patent, then any and all rights granted by such
+ Participant to You under Sections 2.1 and/or 2.2 of this License
+ shall, upon 60 days notice from Participant terminate prospectively,
+ unless if within 60 days after receipt of notice You either: (i)
+ agree in writing to pay Participant a mutually agreeable reasonable
+ royalty for Your past and future use of Modifications made by such
+ Participant, or (ii) withdraw Your litigation claim with respect to
+ the Contributor Version against such Participant. If within 60 days
+ of notice, a reasonable royalty and payment arrangement are not
+ mutually agreed upon in writing by the parties or the litigation claim
+ is not withdrawn, the rights granted by Participant to You under
+ Sections 2.1 and/or 2.2 automatically terminate at the expiration of
+ the 60 day notice period specified above.
+
+ (b) any software, hardware, or device, other than such Participant's
+ Contributor Version, directly or indirectly infringes any patent, then
+ any rights granted to You by such Participant under Sections 2.1(b)
+ and 2.2(b) are revoked effective as of the date You first made, used,
+ sold, distributed, or had made, Modifications made by that
+ Participant.
+
+ 8.3. If You assert a patent infringement claim against Participant
+ alleging that such Participant's Contributor Version directly or
+ indirectly infringes any patent where such claim is resolved (such as
+ by license or settlement) prior to the initiation of patent
+ infringement litigation, then the reasonable value of the licenses
+ granted by such Participant under Sections 2.1 or 2.2 shall be taken
+ into account in determining the amount or value of any payment or
+ license.
+
+ 8.4. In the event of termination under Sections 8.1 or 8.2 above,
+ all end user license agreements (excluding distributors and resellers)
+ which have been validly granted by You or any distributor hereunder
+ prior to termination shall survive termination.
+
+9. LIMITATION OF LIABILITY.
+
+ UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
+ (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL
+ DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE,
+ OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR
+ ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY
+ CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL,
+ WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER
+ COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN
+ INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF
+ LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY
+ RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW
+ PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE
+ EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO
+ THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
+
+10. U.S. GOVERNMENT END USERS.
+
+ The Covered Code is a "commercial item," as that term is defined in
+ 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer
+ software" and "commercial computer software documentation," as such
+ terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48
+ C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995),
+ all U.S. Government End Users acquire Covered Code with only those
+ rights set forth herein.
+
+11. MISCELLANEOUS.
+
+ This License represents the complete agreement concerning subject
+ matter hereof. If any provision of this License is held to be
+ unenforceable, such provision shall be reformed only to the extent
+ necessary to make it enforceable. This License shall be governed by
+ California law provisions (except to the extent applicable law, if
+ any, provides otherwise), excluding its conflict-of-law provisions.
+ With respect to disputes in which at least one party is a citizen of,
+ or an entity chartered or registered to do business in the United
+ States of America, any litigation relating to this License shall be
+ subject to the jurisdiction of the Federal Courts of the Northern
+ District of California, with venue lying in Santa Clara County,
+ California, with the losing party responsible for costs, including
+ without limitation, court costs and reasonable attorneys' fees and
+ expenses. The application of the United Nations Convention on
+ Contracts for the International Sale of Goods is expressly excluded.
+ Any law or regulation which provides that the language of a contract
+ shall be construed against the drafter shall not apply to this
+ License.
+
+12. RESPONSIBILITY FOR CLAIMS.
+
+ As between Initial Developer and the Contributors, each party is
+ responsible for claims and damages arising, directly or indirectly,
+ out of its utilization of rights under this License and You agree to
+ work with Initial Developer and Contributors to distribute such
+ responsibility on an equitable basis. Nothing herein is intended or
+ shall be deemed to constitute any admission of liability.
+
+13. MULTIPLE-LICENSED CODE.
+
+ Initial Developer may designate portions of the Covered Code as
+ "Multiple-Licensed". "Multiple-Licensed" means that the Initial
+ Developer permits you to utilize portions of the Covered Code under
+ Your choice of the NPL or the alternative licenses, if any, specified
+ by the Initial Developer in the file described in Exhibit A.
+
+EXHIBIT A -Mozilla Public License.
+
+ ``The contents of this file are subject to the Mozilla Public License
+ Version 1.1 (the "License"); you may not use this file except in
+ compliance with the License. You may obtain a copy of the License at
+ http://www.mozilla.org/MPL/
+
+ Software distributed under the License is distributed on an "AS IS"
+ basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ License for the specific language governing rights and limitations
+ under the License.
+
+ The Original Code is ______________________________________.
+
+ The Initial Developer of the Original Code is ________________________.
+ Portions created by ______________________ are Copyright (C) ______
+ _______________________. All Rights Reserved.
+
+ Contributor(s): ______________________________________.
+
+ Alternatively, the contents of this file may be used under the terms
+ of the _____ license (the "[___] License"), in which case the
+ provisions of [______] License are applicable instead of those
+ above. If you wish to allow use of your version of this file only
+ under the terms of the [____] License and not to allow others to use
+ your version of this file under the MPL, indicate your decision by
+ deleting the provisions above and replace them with the notice and
+ other provisions required by the [___] License. If you do not delete
+ the provisions above, a recipient may use your version of this file
+ under either the MPL or the [___] License."
+
+ [NOTE: The text of this Exhibit A may differ slightly from the text of
+ the notices in the Source Code files of the Original Code. You should
+ use the text of this Exhibit A rather than the text found in the
+ Original Code Source Code for Your Modifications.]
+
Index: /FCKeditor.Java/tags/2.4/build.xml
===================================================================
--- /FCKeditor.Java/tags/2.4/build.xml (revision 2194)
+++ /FCKeditor.Java/tags/2.4/build.xml (revision 2194)
@@ -0,0 +1,59 @@
+
+
+
GetFolders
: Retrieves a list of folders in the current
+ * folderGetFoldersAndFiles
: Retrives a list of files and folders
+ * in the current folderCreateFolder
: Creates a new folder in the current folderFileUpload
: Stores an uploaded file into the current
+ * folder. (must be sent with POST)mkdir
<DefaultUserFilesPath>
+ */
+ public void init() throws ServletException, IllegalArgumentException {
+ String realDefaultUserFilesPath = getServletContext().getRealPath(
+ ConnectorHandler.getDefaultUserFilesPath());
+
+ File defaultUserFilesDir = new File(realDefaultUserFilesPath);
+ UtilsFile.checkDirAndCreate(defaultUserFilesDir);
+
+ logger.info("ConnectorServlet successfully initialized!");
+ }
+
+ /**
+ * Manage the GET
requests (GetFolders
,
+ * GetFoldersAndFiles
, CreateFolder
).connector?Command=<CommandName>&Type=<ResourceType>&CurrentFolder=<FolderPath>
+ * + * It executes the commands and then returns the result to the client in XML + * format. + *
+ */ + public void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + logger.debug("Entering ConnectorServlet#doGet"); + + response.setCharacterEncoding("UTF-8"); + response.setContentType("application/xml; charset=UTF-8"); + response.setHeader("Cache-Control", "no-cache"); + PrintWriter out = response.getWriter(); + + String commandStr = request.getParameter("Command"); + String typeStr = request.getParameter("Type"); + String currentFolderStr = request.getParameter("CurrentFolder"); + + logger.debug("Parameter Command: {}", commandStr); + logger.debug("Parameter Type: {}", typeStr); + logger.debug("Parameter CurrentFolder: {}", currentFolderStr); + + XmlResponse xr; + + if (!RequestCycleHandler.isEnabledForFileBrowsing(request)) + xr = new XmlResponse(XmlResponse.EN_ERROR, Messages.NOT_AUTHORIZED_FOR_BROWSING); + else if (!CommandHandler.isValidForGet(commandStr)) + xr = new XmlResponse(XmlResponse.EN_ERROR, Messages.INVALID_COMMAND); + else if (typeStr != null && !ResourceTypeHandler.isValid(typeStr)) + xr = new XmlResponse(XmlResponse.EN_ERROR, Messages.INVALID_TYPE); + else if (!UtilsFile.isValidPath(currentFolderStr)) + xr = new XmlResponse(XmlResponse.EN_ERROR, Messages.INVALID_CURRENT_FOLDER); + else { + CommandHandler command = CommandHandler.getCommand(commandStr); + ResourceTypeHandler resourceType = ResourceTypeHandler.getDefaultResourceType(typeStr); + + String typePath = UtilsFile.constructServerSidePath(request, resourceType); + String typeDirPath = getServletContext().getRealPath(typePath); + + File typeDir = new File(typeDirPath); + UtilsFile.checkDirAndCreate(typeDir); + + File currentDir = new File(typeDir, currentFolderStr); + + if (!currentDir.exists()) + xr = new XmlResponse(XmlResponse.EN_INVALID_FOLDER_NAME); + else { + + xr = new XmlResponse(command, resourceType, currentFolderStr, UtilsResponse + .constructResponseUrl(request, resourceType, currentFolderStr, true, + ConnectorHandler.isFullUrl())); + + if (command.equals(CommandHandler.GET_FOLDERS)) + xr.setFolders(currentDir); + else if (command.equals(CommandHandler.GET_FOLDERS_AND_FILES)) + xr.setFoldersAndFiles(currentDir); + else if (command.equals(CommandHandler.CREATE_FOLDER)) { + String newFolderStr = UtilsFile.sanitizeFolderName(request + .getParameter("NewFolderName")); + logger.debug("Parameter NewFolderName: {}", newFolderStr); + + File newFolder = new File(currentDir, newFolderStr); + int errorNumber = XmlResponse.EN_UKNOWN; + + if (newFolder.exists()) + errorNumber = XmlResponse.EN_ALREADY_EXISTS; + else { + try { + errorNumber = (newFolder.mkdir()) ? XmlResponse.EN_OK + : XmlResponse.EN_INVALID_FOLDER_NAME; + } catch (SecurityException e) { + errorNumber = XmlResponse.EN_SECURITY_ERROR; + } + } + xr.setError(errorNumber); + } + } + } + + out.print(xr); + out.flush(); + out.close(); + logger.debug("Exiting ConnectorServlet#doGet"); + } + + /** + * Manage thePOST
requests (FileUpload
).connector?Command=<FileUpload>&Type=<ResourceType>&CurrentFolder=<FolderPath>
+ * with the file in the POST
body.GET
and POST
commands.
+ *
+ * @version $Id$
+ */
+public class CommandHandler {
+
+ private String name;
+ private static Mapnull
, empty, or does not exist.
+ */
+ public static CommandHandler valueOf(final String name) throws IllegalArgumentException {
+ if (Utils.isEmpty(name))
+ throw new IllegalArgumentException();
+
+ if (!isValidForGet(name) && !isValidForPost(name))
+ throw new IllegalArgumentException();
+ return (getCommands.get(name) != null) ? getCommands.get(name) : postCommands.get(name);
+ }
+
+
+ /**
+ * Checks if a specfied string represents a valid GET
+ * command.
+ *
+ * @param name
+ * A command string to check
+ * @return true
if the string representation is valid else
+ * false
.
+ */
+ public static boolean isValidForGet(final String name) {
+ return getCommands.containsKey(name);
+ }
+
+ /**
+ * Checks if a specfied string represents a valid POST
+ * command.
+ *
+ * @param name
+ * A command string to check
+ * @return true
if the string representation is valid else
+ * false
.
+ */
+ public static boolean isValidForPost(final String name) {
+ return postCommands.containsKey(name);
+ }
+
+
+ /**
+ * A wrapper for {@link #valueOf(String)}. It returns null instead of
+ * throwing an exception.
+ *
+ * @param name A command string to check
+ * @return A {@link CommandHandler} object holding the value represented by
+ * the string argument, or null
.
+ */
+ public static CommandHandler getCommand(final String name) {
+ try {
+ return CommandHandler.valueOf(name);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null)
+ return false;
+ try {
+ CommandHandler rt = (CommandHandler) obj;
+ return name.equals(rt.getName());
+ } catch (ClassCastException e) {
+ return false;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public int hashCode() {
+ return name.hashCode();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return name;
+ }
+}
Index: /FCKeditor.Java/tags/2.4/java-core/src/main/java/net/fckeditor/handlers/ConnectorHandler.java
===================================================================
--- /FCKeditor.Java/tags/2.4/java-core/src/main/java/net/fckeditor/handlers/ConnectorHandler.java (revision 2194)
+++ /FCKeditor.Java/tags/2.4/java-core/src/main/java/net/fckeditor/handlers/ConnectorHandler.java (revision 2194)
@@ -0,0 +1,87 @@
+/*
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ * - GNU General Public License Version 2 or later (the "GPL")
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * - Mozilla Public License Version 1.1 or later (the "MPL")
+ * http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ */
+package net.fckeditor.handlers;
+
+import javax.servlet.http.HttpServletRequest;
+
+import net.fckeditor.requestcycle.UserPathBuilder;
+
+/**
+ * Handler for Connector-related properties.UserFilesPath
.
+ *
+ * @return {@link UserPathBuilder#getUserFilesPath(HttpServletRequest)} or
+ * the DefaultUserFilePath
if {@link UserPathBuilder}
+ * isn't set.
+ */
+ public static String getUserFilesPath(final HttpServletRequest request) {
+ String userFilePath = RequestCycleHandler.getUserFilePath(request);
+ return (userFilePath != null) ? userFilePath : getDefaultUserFilesPath();
+ }
+
+ /**
+ * Getter for the default handling of files with multiple extensions.
+ *
+ * @return true
if single extension only should be enforced
+ * else false
.
+ */
+ public static boolean isForceSingleExtension() {
+ return Boolean.valueOf(PropertiesLoader.getProperty("connector.forceSingleExtension"));
+ }
+
+ /**
+ * Getter for the value to instruct the connector to return the full URL of
+ * a file/folder in the XML response rather than the absolute URL.
+ *
+ * @return true
if the property connector.fullUrl
is
+ * set else false
.
+ */
+ public static boolean isFullUrl() {
+ return Boolean.valueOf(PropertiesLoader.getProperty("connector.fullUrl"));
+ }
+
+ /**
+ * Getter for the default UserFilesPath
.
+ *
+ * @return DefaultUserFilesPath
(/userfiles)
+ */
+ public static String getDefaultUserFilesPath() {
+ return PropertiesLoader.getProperty("connector.userFilesPath");
+ }
+
+ /**
+ * Getter for the value to instruct the Connector to check if the uploaded
+ * image is really an image.
+ *
+ * @return Boolean value of the property
+ * connector.secureImageUploads
.
+ */
+ public static boolean isSecureImageUploads() {
+ return Boolean.valueOf(PropertiesLoader.getProperty("connector.secureImageUploads"));
+ }
+}
Index: /FCKeditor.Java/tags/2.4/java-core/src/main/java/net/fckeditor/handlers/ExtensionsHandler.java
===================================================================
--- /FCKeditor.Java/tags/2.4/java-core/src/main/java/net/fckeditor/handlers/ExtensionsHandler.java (revision 2194)
+++ /FCKeditor.Java/tags/2.4/java-core/src/main/java/net/fckeditor/handlers/ExtensionsHandler.java (revision 2194)
@@ -0,0 +1,148 @@
+/*
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ * - GNU General Public License Version 2 or later (the "GPL")
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * - Mozilla Public License Version 1.1 or later (the "MPL")
+ * http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ */
+package net.fckeditor.handlers;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import net.fckeditor.tool.Utils;
+
+/**
+ * This handler manages the allowed and denied extensions for each resource
+ * type. The extensions are preset by the properties managed by
+ * {@link PropertiesLoader}.
+ * + * Hint: It's recommend to use either allowed or denied extensions for one file + * type. Never use both at the same time! That's why denied + * extensions of a file type will be deleted if you set the allowed one and vice + * versa. + *
+ * + * @version $Id$ + */ +public class ExtensionsHandler { + + private static MapextensionsList
is null
, allowed
+ * extensions are kept untouched.
+ *
+ * @param type
+ * The file type.
+ * @param extensionsList
+ * Required format: ext1|ext2|ext3
+ */
+ public static void setExtensionsAllowed(final ResourceTypeHandler type, final String extensionsList) {
+ if (extensionsList != null) {
+ extensionsAllowed.put(type, Utils.getSet(extensionsList));
+ extensionsDenied.get(type).clear();
+ }
+ }
+
+ /**
+ * Getter for the denied extensions of a file type.
+ *
+ * @param type
+ * The file type.
+ * @return Set of denied extensions or an empty set.
+ */
+ public static SetextensionsList
is null
, denied
+ * extensions are kept untouched.
+ *
+ * @param type
+ * The file type.
+ * @param extensionsList
+ * Required format: ext1|ext2|ext3
+ */
+ public static void setExtensionsDenied(final ResourceTypeHandler type, final String extensionsList) {
+ if (extensionsList != null) {
+ extensionsDenied.put(type, Utils.getSet(extensionsList));
+ extensionsAllowed.get(type).clear();
+ }
+ }
+
+ /**
+ * Checks if an extension is allowed for a file type.
+ *
+ * @param type
+ * The resource type you want to check.
+ * @param extension
+ * The extension you want to check.
+ * @return true
is extension is allowed else
+ * false
. Attention: false
+ * is always returned if 'type' or 'extensions' is null
.
+ */
+ public static boolean isAllowed(final ResourceTypeHandler type, final String extension) {
+ if (type == null || extension == null)
+ return false;
+ String ext = extension.toLowerCase();
+ Set/net/fckeditor/handlers/default.properties
and
+ * /fckeditor.properties
.default.properties
fckeditor.properties
if present.fckeditor.properties
will override properties loaded from
+ * default.properties
. (intended behavior)fckeditor.properties
. It should never used inside
+ * FCKeditor.Java!!!
+ *
+ * @param key
+ * The property key.
+ * @param value
+ * The property value.
+ * @see Properties#setProperty(String, String)
+ */
+ public static void setProperty(final String key, final String value) {
+ properties.setProperty(key, value);
+ }
+}
Index: /FCKeditor.Java/tags/2.4/java-core/src/main/java/net/fckeditor/handlers/RequestCycleHandler.java
===================================================================
--- /FCKeditor.Java/tags/2.4/java-core/src/main/java/net/fckeditor/handlers/RequestCycleHandler.java (revision 2194)
+++ /FCKeditor.Java/tags/2.4/java-core/src/main/java/net/fckeditor/handlers/RequestCycleHandler.java (revision 2194)
@@ -0,0 +1,113 @@
+/*
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ * - GNU General Public License Version 2 or later (the "GPL")
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * - Mozilla Public License Version 1.1 or later (the "MPL")
+ * http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ */
+package net.fckeditor.handlers;
+
+import javax.servlet.http.HttpServletRequest;
+
+import net.fckeditor.requestcycle.UserAction;
+import net.fckeditor.requestcycle.UserPathBuilder;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Handler for classes which implement the interfaces from package
+ * {@link net.fckeditor.requestcycle}.
+ *
+ * @version $Id$
+ */
+public class RequestCycleHandler {
+ private static Logger logger = LoggerFactory.getLogger(RequestCycleHandler.class);
+ private static UserAction userAction = null;
+ private static UserPathBuilder userPathBuilder = null;
+
+ static {
+ // If there are more objects to instantiate in future, we could solve the following by reflection!
+
+ // 1. try to instantiate the UserAction object
+ String fqcn = PropertiesLoader.getProperty("connector.userActionImpl");
+ if (fqcn == null)
+ logger.warn("No property found for UserAction implementation, any user action will be disabled!");
+ else {
+ try {
+ Class> clazz = Class.forName(fqcn);
+ userAction = (UserAction) clazz.newInstance();
+ logger.info("UserAction implementation successfully instantiated!");
+ } catch (Exception e) {
+ logger.error("Couldn't instantiate class [".concat(fqcn).concat(
+ "], any user action will disabled!"), e);
+ }
+ }
+
+ // 2. try to instantiate the UserPathBuilder object
+ fqcn = PropertiesLoader.getProperty("connector.userPathBuilderImpl");
+ if (fqcn == null)
+ logger.warn("No property found for UserPathBuilder implementation! "
+ .concat("The 'DefaultUserFilesPath' will be used in the ConnectorServlet!"));
+ else {
+ try {
+ Class> clazz = Class.forName(fqcn);
+ userPathBuilder = (UserPathBuilder) clazz.newInstance();
+ logger.info("UserPathBuilder object successfully instantiated!");
+ } catch (Exception e) {
+ logger.error("Couldn't instantiate class [".concat(fqcn)
+ .concat("], The 'DefaultUserFilesPath' will be used in the ConnectorServlet!"), e);
+ }
+ }
+ }
+
+ /**
+ * Just a wrapper to
+ * {@link UserAction#isEnabledForFileBrowsing(HttpServletRequest)}.
+ *
+ * @param request
+ * @return {@link UserAction#isEnabledForFileBrowsing(HttpServletRequest)}
+ * or false if userAction
isn't set.
+ */
+ public static boolean isEnabledForFileBrowsing(final HttpServletRequest request) {
+ return (userAction != null && userAction.isEnabledForFileBrowsing(request));
+ }
+
+ /**
+ * Just a wrapper to
+ * {@link UserAction#isEnabledForFileUpload(HttpServletRequest)}.
+ *
+ * @param request
+ * @return {@link UserAction#isEnabledForFileUpload(HttpServletRequest)} or
+ * false if userAction
isn't set.
+ */
+ public static boolean isEnabledForFileUpload(final HttpServletRequest request) {
+ return (userAction != null && userAction.isEnabledForFileUpload(request));
+ }
+
+ /**
+ * Getter for the UserFilesPath
.null
if userPathBuilder
is
+ * null
.
+ */
+ protected static String getUserFilePath(final HttpServletRequest request) {
+ return (userPathBuilder != null) ? userPathBuilder.getUserFilesPath(request) : null;
+ }
+}
Index: /FCKeditor.Java/tags/2.4/java-core/src/main/java/net/fckeditor/handlers/ResourceTypeHandler.java
===================================================================
--- /FCKeditor.Java/tags/2.4/java-core/src/main/java/net/fckeditor/handlers/ResourceTypeHandler.java (revision 2194)
+++ /FCKeditor.Java/tags/2.4/java-core/src/main/java/net/fckeditor/handlers/ResourceTypeHandler.java (revision 2194)
@@ -0,0 +1,179 @@
+/*
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ * - GNU General Public License Version 2 or later (the "GPL")
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * - Mozilla Public License Version 1.1 or later (the "MPL")
+ * http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ */
+package net.fckeditor.handlers;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import net.fckeditor.tool.Utils;
+
+/**
+ * Handler for different resource types.
+ *
+ * @version $Id$
+ */
+public class ResourceTypeHandler {
+
+ private String name;
+ private static Mapnull
, empty, or does not exist.
+ */
+ public static ResourceTypeHandler valueOf(final String name) throws IllegalArgumentException {
+ if (Utils.isEmpty(name))
+ throw new IllegalArgumentException();
+
+ ResourceTypeHandler rt = types.get(name);
+ if (rt == null)
+ throw new IllegalArgumentException();
+ return rt;
+ }
+
+ /**
+ *
+ * Checks if a specfied string represents a valid resource type.
+ *
+ * @param name
+ * A resource type string to check.
+ * @return true
if the string representation is valid else
+ * false
.
+ */
+ public static boolean isValid(final String name) {
+ return types.containsKey(name);
+ }
+
+ /**
+ * Tries to determine ResourceType from string and return {@link #FILE} if
+ * provided string is invalid.
+ *
+ * @param name
+ * @return resource type
+ */
+ public static ResourceTypeHandler getDefaultResourceType(final String name) {
+ ResourceTypeHandler rt = getResourceType(name);
+ return rt == null ? FILE : rt;
+ }
+
+ /**
+ * A wrapper for {@link #valueOf(String)}. It returns null
+ * instead of throwing an exception.
+ *
+ * @param name
+ * A resource type string to check.
+ * @return A {@link ResourceTypeHandler} object holding the value
+ * represented by the string argument, or null
.
+ */
+ public static ResourceTypeHandler getResourceType(final String name) {
+ try {
+ return ResourceTypeHandler.valueOf(name);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null)
+ return false;
+ try {
+ ResourceTypeHandler rt = (ResourceTypeHandler) obj;
+ return name.equals(rt.getName());
+ } catch (ClassCastException e) {
+ return false;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public int hashCode() {
+ return name.hashCode();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return name;
+ }
+}
Index: /FCKeditor.Java/tags/2.4/java-core/src/main/java/net/fckeditor/requestcycle/UserAction.java
===================================================================
--- /FCKeditor.Java/tags/2.4/java-core/src/main/java/net/fckeditor/requestcycle/UserAction.java (revision 2194)
+++ /FCKeditor.Java/tags/2.4/java-core/src/main/java/net/fckeditor/requestcycle/UserAction.java (revision 2194)
@@ -0,0 +1,62 @@
+/*
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ * - GNU General Public License Version 2 or later (the "GPL")
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * - Mozilla Public License Version 1.1 or later (the "MPL")
+ * http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ */
+package net.fckeditor.requestcycle;
+
+import javax.servlet.http.HttpServletRequest;
+
+
+/**
+ * An interface which provides the authorization of server-side commands.true
.
+ *
+ * @param request
+ * Servlet request from user
+ * @return true
if user can upload to the server, or
+ * false
+ */
+ public boolean isEnabledForFileUpload(final HttpServletRequest request);
+
+ /**
+ * Authenticates/enables the current user for browsing files.true
.
+ *
+ * @param request
+ * Servlet request from user
+ * @return true
if user can browse the server, or
+ * false
+ */
+ public boolean isEnabledForFileBrowsing(final HttpServletRequest request);
+
+}
Index: /FCKeditor.Java/tags/2.4/java-core/src/main/java/net/fckeditor/requestcycle/UserPathBuilder.java
===================================================================
--- /FCKeditor.Java/tags/2.4/java-core/src/main/java/net/fckeditor/requestcycle/UserPathBuilder.java (revision 2194)
+++ /FCKeditor.Java/tags/2.4/java-core/src/main/java/net/fckeditor/requestcycle/UserPathBuilder.java (revision 2194)
@@ -0,0 +1,52 @@
+/*
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ * - GNU General Public License Version 2 or later (the "GPL")
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * - Mozilla Public License Version 1.1 or later (the "MPL")
+ * http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ */
+package net.fckeditor.requestcycle;
+
+import javax.servlet.http.HttpServletRequest;
+
+import net.fckeditor.handlers.ConnectorHandler;
+
+/**
+ * An interface which provides a way to build a user-dependent
+ * UserFilesPath
.
+ *
+ * @version $Id$
+ */
+public interface UserPathBuilder {
+
+ /**
+ * Getter for the user-dependent UserFilesPath
.null
,
+ * {@link ConnectorHandler} will used the default one! That's useful, if the
+ * implementation doesn't bother you.null
or the UserFilesPath
for the
+ * current user.
+ */
+ public String getUserFilesPath(final HttpServletRequest request);
+}
Index: /FCKeditor.Java/tags/2.4/java-core/src/main/java/net/fckeditor/requestcycle/impl/UserActionImpl.java
===================================================================
--- /FCKeditor.Java/tags/2.4/java-core/src/main/java/net/fckeditor/requestcycle/impl/UserActionImpl.java (revision 2194)
+++ /FCKeditor.Java/tags/2.4/java-core/src/main/java/net/fckeditor/requestcycle/impl/UserActionImpl.java (revision 2194)
@@ -0,0 +1,49 @@
+/*
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ * - GNU General Public License Version 2 or later (the "GPL")
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * - Mozilla Public License Version 1.1 or later (the "MPL")
+ * http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ */
+package net.fckeditor.requestcycle.impl;
+
+import javax.servlet.http.HttpServletRequest;
+
+import net.fckeditor.requestcycle.UserAction;
+
+/**
+ * Standard implementation for {@link UserAction}. It always returns
+ * true
.
+ *
+ * @version $Id$
+ */
+public class UserActionImpl implements UserAction {
+
+ /* (non-Javadoc)
+ * @see net.fckeditor.requestcycle.UserAction#isEnabledForFileBrowsing(javax.servlet.http.HttpServletRequest)
+ */
+ public boolean isEnabledForFileBrowsing(final HttpServletRequest request) {
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see net.fckeditor.requestcycle.UserAction#isEnabledForFileUpload(javax.servlet.http.HttpServletRequest)
+ */
+ public boolean isEnabledForFileUpload(final HttpServletRequest request) {
+ return true;
+ }
+
+}
Index: /FCKeditor.Java/tags/2.4/java-core/src/main/java/net/fckeditor/response/UploadResponse.java
===================================================================
--- /FCKeditor.Java/tags/2.4/java-core/src/main/java/net/fckeditor/response/UploadResponse.java (revision 2194)
+++ /FCKeditor.Java/tags/2.4/java-core/src/main/java/net/fckeditor/response/UploadResponse.java (revision 2194)
@@ -0,0 +1,161 @@
+/*
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ * - GNU General Public License Version 2 or later (the "GPL")
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * - Mozilla Public License Version 1.1 or later (the "MPL")
+ * http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ */
+package net.fckeditor.response;
+
+import net.fckeditor.connector.Messages;
+import net.fckeditor.tool.Utils;
+
+/**
+ * Simply abstracts from the JavaScript callback to a Java object.
+ *
+ *
+ * The usage is quite easy but can be tricky since varargs are used in the class
+ * constructor.
The requestor expects a JS method callback with variable
+ * arguments size.
+ *
+ * e.g.
+ * window.parent.OnUploadCompleted(101,'some/url/file.img','file.img','no error');
+ *
+ * The UploadResponse constructor behaves the same way by simply calling it
+ * with:
+ * UploadResponse ur = new UploadResonse(SC_SOME_ERROR,"/some/url/file.img","file.img","no error"):
+ *
+ * Put the desired parameters in the constructor. You may omit them from
+ * right to left but you have to remain the order.
e.g.
+ * UploadResponse(SC_OK,"/some/url/to/pic.jpg","pic")
or
+ * UploadResponse(SC_OK)
but not
+ * UploadResponse(SC_OK,"some error message")
+ *
+ * Use, if possible, the pre-defined error numbers or upload responses. + *
+ *
+ * If you need to set error number and message only, use constructor with
+ * one parameter and call {@link UploadResponse#setCustomMessage(String)}.
+ *
+ * @param arguments
+ * possible argument order:
+ *
+ * Use the class like this:
+ *
+ * Known limitations:
+ *
+ * Requirements:
+ *
+ * The latest version can be found at http://schmidt.devlib.org/image-info/.
+ *
+ * Written by Marco Schmidt.
+ *
+ * This class is contributed to the Public Domain.
+ * Use it at your own risk.
+ *
+ * History:
+ * This sample displays a normal HTML form with an FCKeditor with
+ full features enabled. Basic FCKeditor informations:int errorNumber, String fileUrl, String filename, String customMessage
+ * @throws IllegalArgumentException
+ * if amount of arguments is less than 1 and above 4
+ * @throws IllegalArgumentException
+ * if the first argument is not an error number (int)
+ */
+ public UploadResponse(Object... arguments) throws IllegalArgumentException {
+ if (arguments.length < 1 || arguments.length > 4)
+ throw new IllegalArgumentException(
+ "The amount of arguments has to be between 1 and 4");
+
+ parameters = new Object[arguments.length];
+
+ if (!(arguments[0] instanceof Integer))
+ throw new IllegalArgumentException(
+ "The first argument has to be an error number (int)");
+
+ System.arraycopy(arguments, 0, parameters, 0, arguments.length);
+ }
+
+ /**
+ * Sets the message in the UploadResponse
.
+ *
+ * Methods automatically determines how many arguments are set and puts the
+ * message at the end.
+ *
+ * @param customMassage
+ * the message you want to pass to the user
+ */
+ public void setCustomMessage(final String customMassage) {
+ if (Utils.isNotEmpty(customMassage)) {
+ if (parameters.length == 1) {
+ Object errorNumber = parameters[0];
+ parameters = new Object[4];
+ parameters[0] = errorNumber;
+ parameters[1] = null;
+ parameters[2] = null;
+ }
+ parameters[3] = customMassage;
+ }
+ }
+
+ /**
+ * Assembles the JavaScript method for the user callback
+ */
+ @Override
+ public String toString() {
+ StringBuffer sb = new StringBuffer(400);
+ sb.append("");
+
+ return sb.toString();
+ }
+}
Index: /FCKeditor.Java/tags/2.4/java-core/src/main/java/net/fckeditor/response/XmlResponse.java
===================================================================
--- /FCKeditor.Java/tags/2.4/java-core/src/main/java/net/fckeditor/response/XmlResponse.java (revision 2194)
+++ /FCKeditor.Java/tags/2.4/java-core/src/main/java/net/fckeditor/response/XmlResponse.java (revision 2194)
@@ -0,0 +1,253 @@
+/*
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ * - GNU General Public License Version 2 or later (the "GPL")
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * - Mozilla Public License Version 1.1 or later (the "MPL")
+ * http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ */
+package net.fckeditor.response;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.StringWriter;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import net.fckeditor.handlers.CommandHandler;
+import net.fckeditor.handlers.ResourceTypeHandler;
+import net.fckeditor.tool.Utils;
+
+import org.apache.commons.io.filefilter.DirectoryFileFilter;
+import org.apache.commons.io.filefilter.FileFileFilter;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * Creates an XML response for every GET
request of the Connector
+ * servlet. This class maps directly to the XML layout descibed here.
+ *
+ * @version $Id$
+ *
+ */
+public class XmlResponse {
+
+ private Document document;
+ private Element errorElement;
+ private Element foldersElement;
+ private Element filesElement;
+
+ /** Error number OK */
+ public static final int EN_OK = 0;
+
+ /** Error number ERROR */
+ public static final int EN_ERROR = 1;
+
+ /** Error number ALREADY EXISTS */
+ public static final int EN_ALREADY_EXISTS = 101;
+
+ /** Error number INVALID FOLDER NAME */
+ public static final int EN_INVALID_FOLDER_NAME = 102;
+
+ /** Error number SECURITY ERROR */
+ public static final int EN_SECURITY_ERROR = 103;
+
+ /** Error number UNKNOWN ERROR */
+ public static final int EN_UKNOWN = 110;
+
+ /**
+ * Use this contructor if want to respond a positive message.
+ *
+ * @param command
+ * @param resourceType
+ * @param currentFolder
+ * @param constructedUrl
+ */
+ public XmlResponse(CommandHandler command, ResourceTypeHandler resourceType,
+ String currentFolder, String constructedUrl) {
+
+ try {
+ DocumentBuilderFactory factory = DocumentBuilderFactory
+ .newInstance();
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ document = builder.newDocument();
+ } catch (ParserConfigurationException e) {
+ throw new RuntimeException(e);
+ }
+
+ Element root = document.createElement("Connector");
+ document.appendChild(root);
+ root.setAttribute("command", command.toString());
+ root.setAttribute("resourceType", resourceType.toString());
+
+ Element currentFolderElement = document.createElement("CurrentFolder");
+ currentFolderElement.setAttribute("path", currentFolder);
+
+ currentFolderElement.setAttribute("url", constructedUrl);
+ root.appendChild(currentFolderElement);
+
+ }
+
+ /**
+ *
+ * Use this contructor if want to respond a negative/error message with
+ * custom text.
+ *
+ * @param number
+ * @param text
+ */
+ public XmlResponse(int number, String text) {
+ try {
+ DocumentBuilderFactory factory = DocumentBuilderFactory
+ .newInstance();
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ document = builder.newDocument();
+ } catch (ParserConfigurationException e) {
+ throw new RuntimeException(e);
+ }
+
+ Element root = document.createElement("Connector");
+ document.appendChild(root);
+ setError(number, text);
+ }
+
+ /**
+ * Use this contructor if want to respond a negative/error message only.
+ *
+ * @param number
+ */
+ public XmlResponse(int number) {
+ this(number, null);
+ }
+
+ /**
+ * Sets an error number with a custom message.
+ *
+ * @param number
+ * @param text
+ */
+ public void setError(int number, String text) {
+
+ if (errorElement == null) {
+ errorElement = document.createElement("Error");
+ document.getDocumentElement().appendChild(errorElement);
+ }
+
+ errorElement.setAttribute("number", String.valueOf(number));
+ if (Utils.isNotEmpty(text))
+ errorElement.setAttribute("text", text);
+
+ }
+
+ /**
+ * Sets an error number.
+ *
+ * @param number
+ */
+ public void setError(int number) {
+ setError(number, null);
+ }
+
+ /**
+ * Lists all folders in the given dir as XML tags.
+ * @param dir
+ */
+ public void setFolders(File dir) {
+
+ if (foldersElement != null) {
+ Element parent = (Element) foldersElement.getParentNode();
+ parent.removeChild(foldersElement);
+ }
+
+ foldersElement = document.createElement("Folders");
+ document.getDocumentElement().appendChild(foldersElement);
+
+ String[] fileList = dir.list(DirectoryFileFilter.DIRECTORY);
+ for (String file : fileList) {
+ Element folderElement = document.createElement("Folder");
+ folderElement.setAttribute("name", file);
+ foldersElement.appendChild(folderElement);
+ }
+ }
+
+ /**
+ * Lists all files in the given dir as XML tags.
+ *
+ * @param dir
+ */
+ public void setFiles(File dir) {
+
+ if (filesElement != null) {
+ Element parent = (Element) filesElement.getParentNode();
+ parent.removeChild(filesElement);
+ }
+
+ filesElement = document.createElement("Files");
+ document.getDocumentElement().appendChild(filesElement);
+
+ File[] fileList = dir.listFiles((FileFilter) FileFileFilter.FILE);
+ long length;
+ for (File file : fileList) {
+ Element fileElement = document.createElement("File");
+ fileElement.setAttribute("name", file.getName());
+ if (file.length() < 1024)
+ length = 1L;
+ else
+ length = file.length()/1024;
+ fileElement.setAttribute("size", String.valueOf(length));
+ filesElement.appendChild(fileElement);
+ }
+ }
+
+ /**
+ * Lists all folders and files in the given dir as XML tags.
+ *
+ * @param dir
+ */
+ public void setFoldersAndFiles(File dir) {
+ setFolders(dir);
+ setFiles(dir);
+ }
+
+ @Override
+ public String toString() {
+ document.getDocumentElement().normalize();
+ TransformerFactory factory = TransformerFactory.newInstance();
+
+ StringWriter sw = new StringWriter();
+
+ try {
+ Transformer transformer = factory.newTransformer();
+
+ DOMSource source = new DOMSource(document);
+ StreamResult result = new StreamResult(sw);
+
+ transformer.transform(source, result);
+ } catch (TransformerException e) {
+ throw new RuntimeException(e);
+ }
+
+ return sw.toString();
+ }
+
+}
Index: /FCKeditor.Java/tags/2.4/java-core/src/main/java/net/fckeditor/tags/CheckTag.java
===================================================================
--- /FCKeditor.Java/tags/2.4/java-core/src/main/java/net/fckeditor/tags/CheckTag.java (revision 2194)
+++ /FCKeditor.Java/tags/2.4/java-core/src/main/java/net/fckeditor/tags/CheckTag.java (revision 2194)
@@ -0,0 +1,122 @@
+/*
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ * - GNU General Public License Version 2 or later (the "GPL")
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * - Mozilla Public License Version 1.1 or later (the "MPL")
+ * http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ */
+package net.fckeditor.tags;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.JspTagException;
+import javax.servlet.jsp.JspWriter;
+import javax.servlet.jsp.tagext.TagSupport;
+
+import net.fckeditor.handlers.PropertiesLoader;
+import net.fckeditor.handlers.RequestCycleHandler;
+import net.fckeditor.tool.Compatibility;
+
+/**
+ * This tag displays information about browser and user capabilities. There are
+ * tree available commands (CompatibleBrowser, FileBrowsing, FileUpload) which
+ * respond an English message.
+ * Hint: The message string cannot be localized at the moment.
+ *
+ * @version $Id$
+ */
+public class CheckTag extends TagSupport {
+
+ private static final long serialVersionUID = -6834095891675681686L;
+
+ private static final String FILE_UPLOAD = "FileUpload";
+ private static final String FILE_BROWSING = "FileBrowsing";
+ private static final String COMPATIBLE_BROWSER = "CompatibleBrowser";
+ private static final String PROPERTY_MESSAGE_FILE_BROWSING_DISABLED = "message.enabled_tag.connector.file_browsing.disabled";
+ private static final String PROPERTY_MESSAGE_FILE_BROWSING_ENABLED = "message.enabled_tag.connector.file_browsing.enabled";
+ private static final String PROPERTY_MESSAGE_FILE_UPLOAD_DISABLED = "message.enabled_tag.connector.file_upload.disalbed";
+ private static final String PROPERTY_MESSAGE_FILE_UPLOAD_ENABLED = "message.enabled_tag.connector.file_upload.enabled";
+ private static final String PROPERTY_MESSAGE_NOT_COMPATIBLE_BROWSER = "message.enabled_tag.compatible_browser.no";
+ private static final String PROPERTY_MESSAGE_COMPATIBLE_BROWSER = "message.enabled_tag.compatible_browser.yes";
+ private static Set
+ * Attention: This tag can only be nested with an editor tag.
+ *
+ * @version $Id$
+ */
+public class ConfigTag extends TagSupport implements DynamicAttributes {
+
+ private Maptrue
if compatible otherwise false
+ */
+ public static boolean check(final String userAgentString) {
+ if (Utils.isEmpty(userAgentString))
+ return false;
+
+ String userAgentStr = userAgentString.toLowerCase();
+
+ // IE 5.5+, check special keys like 'Opera' and 'mac', because there are some
+ // other browsers, containing 'MSIE' in there agent string!
+ if (userAgentStr.indexOf("opera") < 0 && userAgentStr.indexOf("mac") < 0) {
+ if (getBrowserVersion(userAgentStr, ".*msie ([\\d]+.[\\d]+).*") >= 5.5f)
+ return true;
+ }
+
+ // for all gecko based browsers
+ if (getBrowserVersion(userAgentStr, ".*rv:([\\d]+.[\\d]+).*") > 1.7f)
+ return true;
+
+ // Opera 9.5+
+ if (getBrowserVersion(userAgentStr, "opera/([\\d]+.[\\d]+).*") >= 9.5f
+ || getBrowserVersion(userAgentStr, ".*opera ([\\d]+.[\\d]+)") >= 9.5f)
+ return true;
+
+ // Safari 3+
+ if (getBrowserVersion(userAgentStr, ".*applewebkit/([\\d]+).*") >= 522f)
+ return true;
+
+ return false;
+ }
+
+ /**
+ * Just a wrapper to {@link #check(String)}.
+ *
+ * @param request
+ */
+ public static boolean isCompatibleBrowser(final HttpServletRequest request) {
+ return (request == null) ? false : check(request.getHeader("user-agent"));
+ }
+
+ /**
+ * Helper method to get the browser version from 'userAgent' with regex. The
+ * first matching group has to be the version number!
+ *
+ * @param userAgent
+ * @param regex
+ * @return The browser version, or -1f if version can't be determined.
+ */
+ private static float getBrowserVersion(final String userAgent, final String regex) {
+ Pattern pattern = Pattern.compile(regex);
+ Matcher matcher = pattern.matcher(userAgent);
+ if (matcher.matches()) {
+ try {
+ return Float.parseFloat(matcher.group(1));
+ } catch (NumberFormatException e) {
+ return -1f;
+ }
+ }
+ return -1f;
+ }
+
+}
Index: /FCKeditor.Java/tags/2.4/java-core/src/main/java/net/fckeditor/tool/Utils.java
===================================================================
--- /FCKeditor.Java/tags/2.4/java-core/src/main/java/net/fckeditor/tool/Utils.java (revision 2194)
+++ /FCKeditor.Java/tags/2.4/java-core/src/main/java/net/fckeditor/tool/Utils.java (revision 2194)
@@ -0,0 +1,92 @@
+/*
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ * - GNU General Public License Version 2 or later (the "GPL")
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * - Mozilla Public License Version 1.1 or later (the "MPL")
+ * http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ */
+package net.fckeditor.tool;
+
+import java.util.HashSet;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+/**
+ * Some static helper methods.
+ *
+ * @version $Id$
+ */
+public class Utils {
+
+ /**
+ * Constructs a set of uppercased strings from a delimiter-separated string.
+ *
+ * @param stringList
+ * @param delimiter
+ * The delimiter.
+ * @return An emtpy list if 'stringList' is empty else a lowercased set of
+ * strings.
+ * @throws IllegalArgumentException
+ * if 'delimiter' is empty.
+ */
+ public static Setnull
or empty.
+ *
+ * @param str
+ * to check
+ * @return true
if the string is null
.
+ */
+ public static boolean isEmpty(final String str) {
+ return str == null || str.length() == 0;
+ }
+
+ /**
+ * Just a wrapper to {@link #isEmpty(String)}.
+ *
+ * @param str
+ * @return true
if the String is not empty and not
+ * null
.
+ */
+ public static boolean isNotEmpty(final String str) {
+ return !isEmpty(str);
+ }
+}
Index: /FCKeditor.Java/tags/2.4/java-core/src/main/java/net/fckeditor/tool/UtilsFile.java
===================================================================
--- /FCKeditor.Java/tags/2.4/java-core/src/main/java/net/fckeditor/tool/UtilsFile.java (revision 2194)
+++ /FCKeditor.Java/tags/2.4/java-core/src/main/java/net/fckeditor/tool/UtilsFile.java (revision 2194)
@@ -0,0 +1,167 @@
+/*
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ * - GNU General Public License Version 2 or later (the "GPL")
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * - Mozilla Public License Version 1.1 or later (the "MPL")
+ * http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ */
+package net.fckeditor.tool;
+
+import java.io.File;
+import java.io.InputStream;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.commons.io.FilenameUtils;
+import org.devlib.schmidt.imageinfo.ImageInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import net.fckeditor.handlers.ConnectorHandler;
+import net.fckeditor.handlers.ResourceTypeHandler;
+
+/**
+ * Some static helper methods in conjunction with files.
+ *
+ * @version $Id$
+ */
+public class UtilsFile {
+
+ private static final Logger logger = LoggerFactory.getLogger(UtilsFile.class);
+
+ /**
+ * Do a cleanup of the file name to avoid possible problems.
+ * The forceSingleExtension
property will be respected!
+ *
+ * @param fileName
+ * @return folder name where \ / | : ? * " < > 'control chars' replaced by '_'
+ */
+ public static String sanitizeFileName(final String fileName) {
+ if (fileName == null)
+ return null;
+ if (fileName.equals(""))
+ return "";
+
+ String name = (ConnectorHandler.isForceSingleExtension()) ? UtilsFile.forceSingleExtension(fileName)
+ : fileName;
+
+ // Remove \ / | : ? * " < > with _
+ return name.replaceAll("\\/|\\/|\\||:|\\?|\\*|\"|<|>|\\p{Cntrl}", "_");
+ }
+
+ /**
+ * Do a cleanup of the folder name to avoid possible problems.
+ *
+ * @param folderName
+ * @return folder name where . \ / | : ? * " < > 'control chars'
+ * replaced by '_'
+ */
+ public static String sanitizeFolderName(final String folderName) {
+ if (folderName == null)
+ return null;
+ if (folderName.equals(""))
+ return "";
+
+ // Remove . \ / | : ? * " < > with _
+ return folderName.replaceAll("\\.|\\/|\\/|\\||:|\\?|\\*|\"|<|>|\\p{Cntrl}", "_");
+ }
+
+ /**
+ * Checks if the underlying file of the InputStream is an image.
+ *
+ * @param in An input stream
+ * @return
true
if the underlying file is an image else
+ * false
.
+ */
+ public static boolean isImage(final InputStream in) {
+ ImageInfo ii = new ImageInfo();
+ ii.setInput(in);
+ return ii.check();
+ }
+
+ /**
+ * Checks if a path corresponds to the rules defined here.
+ *
+ * @param path
+ * @return true
if path corresponds to rules or
+ * false
.
+ */
+ public static boolean isValidPath(final String path) {
+ if (Utils.isEmpty(path))
+ return false;
+ if (!path.startsWith("/"))
+ return false;
+ if (!path.endsWith("/"))
+ return false;
+
+ if (!path.equals(FilenameUtils.separatorsToUnix(FilenameUtils
+ .normalize(path))))
+ return false;
+
+ return true;
+ }
+
+ /**
+ * Replaces all dots except the last one with underscores in a filename.
+ *
+ * @param filename
+ * @return string with a single dot only
+ */
+ public static String forceSingleExtension(final String filename) {
+ return filename.replaceAll("\\.(?![^.]+$)", "_");
+ }
+
+ /**
+ * Checks if a filename contains more than one dot.
+ *
+ * @param filename
+ * @return true
if filename contains severals dots else
+ * false
+ */
+ public static boolean isSingleExtension(final String filename) {
+ return filename.matches("[^\\.]+\\.[^\\.]+");
+ }
+
+ /**
+ * Checks for a dir and creates it if it does not exist.
+ *
+ * @param dir Directory to check/create.
+ */
+ public static void checkDirAndCreate(File dir) {
+ if (!dir.exists()) {
+ dir.mkdirs();
+ logger.debug("Dir '{}' successfully created", dir);
+ }
+ }
+
+ /**
+ * Compose server-side response path.
+ *
+ * @param request
+ * @param resourceType
+ * @return server-side path of resourceType
.
+ */
+ public static String constructServerSidePath(HttpServletRequest request,
+ ResourceTypeHandler resourceType) {
+ StringBuffer sb = new StringBuffer(ConnectorHandler
+ .getUserFilesPath(request));
+ sb.append(resourceType.getPath());
+
+ return sb.toString();
+ }
+
+}
Index: /FCKeditor.Java/tags/2.4/java-core/src/main/java/net/fckeditor/tool/UtilsResponse.java
===================================================================
--- /FCKeditor.Java/tags/2.4/java-core/src/main/java/net/fckeditor/tool/UtilsResponse.java (revision 2194)
+++ /FCKeditor.Java/tags/2.4/java-core/src/main/java/net/fckeditor/tool/UtilsResponse.java (revision 2194)
@@ -0,0 +1,70 @@
+/*
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ * - GNU General Public License Version 2 or later (the "GPL")
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * - Mozilla Public License Version 1.1 or later (the "MPL")
+ * http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ */
+package net.fckeditor.tool;
+
+import javax.servlet.http.HttpServletRequest;
+
+import net.fckeditor.handlers.ConnectorHandler;
+import net.fckeditor.handlers.ResourceTypeHandler;
+
+/**
+ * Some static helper methods in conjunction with the servlet response.
+ *
+ * @version $Id$
+ */
+public class UtilsResponse {
+
+ /**
+ * Constructs a URL from different parameters. This method is about to
+ * change in version 2.5.
+ *
+ * @param request
+ * @param resourceType
+ * @param urlPath
+ * @param prependContextPath
+ * @param fullUrl
+ * @return constructed url
+ */
+ public static String constructResponseUrl(HttpServletRequest request,
+ ResourceTypeHandler resourceType, String urlPath,
+ boolean prependContextPath, boolean fullUrl) {
+
+ StringBuffer sb = new StringBuffer();
+
+ if (fullUrl) {
+ String address = request.getRequestURL().toString();
+ sb.append(address.substring(0, address.indexOf('/', 8))
+ + request.getContextPath());
+ }
+
+ if (prependContextPath && !fullUrl)
+ sb.append(request.getContextPath());
+
+ sb.append(ConnectorHandler.getUserFilesPath(request));
+ sb.append(resourceType.getPath());
+
+ if (Utils.isNotEmpty(urlPath))
+ sb.append(urlPath);
+
+ return sb.toString();
+ }
+
+}
Index: /FCKeditor.Java/tags/2.4/java-core/src/main/java/net/fckeditor/tool/XHtmlTagTool.java
===================================================================
--- /FCKeditor.Java/tags/2.4/java-core/src/main/java/net/fckeditor/tool/XHtmlTagTool.java (revision 2194)
+++ /FCKeditor.Java/tags/2.4/java-core/src/main/java/net/fckeditor/tool/XHtmlTagTool.java (revision 2194)
@@ -0,0 +1,137 @@
+/*
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ * - GNU General Public License Version 2 or later (the "GPL")
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * - Mozilla Public License Version 1.1 or later (the "MPL")
+ * http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ */
+package net.fckeditor.tool;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Tool to construct a XHTML tag.
+ *
+ * Usage:
+ *
+ * XHtmlTagTool tag = XHtmlTagTool("a", "link");
+ * tag.addAttribute("href", "http://google.com");
+ * tag.toString();: <a href="http://google.com">link</a>
+ *
+ *
+ * Hint:
+ *
+ *
+ *
+ * @version $Id$
+ */
+public class XHtmlTagTool {
+
+ /** Name of the tag. */
+ private String name;
+
+ /** Container for the attributes. */
+ private Map
+ * ImageInfo ii = new ImageInfo();
+ * ii.setInput(in); // in can be InputStream or RandomAccessFile
+ * ii.setDetermineImageNumber(true); // default is false
+ * ii.setCollectComments(true); // default is false
+ * if (!ii.check()) {
+ * System.err.println("Not a supported image file format.");
+ * return;
+ * }
+ * System.out.println(ii.getFormatName() + ", " + ii.getMimeType() +
+ * ", " + ii.getWidth() + " x " + ii.getHeight() + " pixels, " +
+ * ii.getBitsPerPixel() + " bits per pixel, " + ii.getNumberOfImages() +
+ * " image(s), " + ii.getNumberOfComments() + " comment(s).");
+ * // there are other properties, check out the API documentation
+ *
+ * You can also use this class as a command line program.
+ * Call it with a number of image file names and URLs as parameters:
+ *
+ * java ImageInfo *.jpg *.png *.gif http://somesite.tld/image.jpg
+ *
+ * or call it without parameters and pipe data to it:
+ *
+ * java ImageInfo < image.jpg
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ * @author Marco Schmidt
+ */
+@SuppressWarnings("unchecked")
+public class ImageInfo {
+ /**
+ * Return value of {@link #getFormat()} for JPEG streams.
+ * ImageInfo can extract physical resolution and comments
+ * from JPEGs (only from APP0 headers).
+ * Only one image can be stored in a file.
+ * It is determined whether the JPEG stream is progressive
+ * (see {@link #isProgressive()}).
+ */
+ public static final int FORMAT_JPEG = 0;
+
+ /**
+ * Return value of {@link #getFormat()} for GIF streams.
+ * ImageInfo can extract comments from GIFs and count the number
+ * of images (GIFs with more than one image are animations).
+ * It is determined whether the GIF stream is interlaced (see {@link #isProgressive()}).
+ */
+ public static final int FORMAT_GIF = 1;
+
+ /**
+ * Return value of {@link #getFormat()} for PNG streams.
+ * PNG only supports one image per file.
+ * Both physical resolution and comments can be stored with PNG,
+ * but ImageInfo is currently not able to extract those.
+ * It is determined whether the PNG stream is interlaced (see {@link #isProgressive()}).
+ */
+ public static final int FORMAT_PNG = 2;
+
+ /**
+ * Return value of {@link #getFormat()} for BMP streams.
+ * BMP only supports one image per file.
+ * BMP does not allow for comments.
+ * The physical resolution can be stored.
+ */
+ public static final int FORMAT_BMP = 3;
+
+ /**
+ * Return value of {@link #getFormat()} for PCX streams.
+ * PCX does not allow for comments or more than one image per file.
+ * However, the physical resolution can be stored.
+ */
+ public static final int FORMAT_PCX = 4;
+
+ /**
+ * Return value of {@link #getFormat()} for IFF streams.
+ */
+ public static final int FORMAT_IFF = 5;
+
+ /**
+ * Return value of {@link #getFormat()} for RAS streams.
+ * Sun Raster allows for one image per file only and is not able to
+ * store physical resolution or comments.
+ */
+ public static final int FORMAT_RAS = 6;
+
+ /** Return value of {@link #getFormat()} for PBM streams. */
+ public static final int FORMAT_PBM = 7;
+
+ /** Return value of {@link #getFormat()} for PGM streams. */
+ public static final int FORMAT_PGM = 8;
+
+ /** Return value of {@link #getFormat()} for PPM streams. */
+ public static final int FORMAT_PPM = 9;
+
+ /** Return value of {@link #getFormat()} for PSD streams. */
+ public static final int FORMAT_PSD = 10;
+
+/* public static final int COLOR_TYPE_UNKNOWN = -1;
+ public static final int COLOR_TYPE_TRUECOLOR_RGB = 0;
+ public static final int COLOR_TYPE_PALETTED = 1;
+ public static final int COLOR_TYPE_GRAYSCALE= 2;
+ public static final int COLOR_TYPE_BLACK_AND_WHITE = 3;*/
+
+ /**
+ * The names of all supported file formats.
+ * The FORMAT_xyz int constants can be used as index values for
+ * this array.
+ */
+ private static final String[] FORMAT_NAMES =
+ {"JPEG", "GIF", "PNG", "BMP", "PCX",
+ "IFF", "RAS", "PBM", "PGM", "PPM",
+ "PSD"};
+
+ /**
+ * The names of the MIME types for all supported file formats.
+ * The FORMAT_xyz int constants can be used as index values for
+ * this array.
+ */
+ private static final String[] MIME_TYPE_STRINGS =
+ {"image/jpeg", "image/gif", "image/png", "image/bmp", "image/pcx",
+ "image/iff", "image/ras", "image/x-portable-bitmap", "image/x-portable-graymap", "image/x-portable-pixmap",
+ "image/psd"};
+
+ private int width;
+ private int height;
+ private int bitsPerPixel;
+ //private int colorType = COLOR_TYPE_UNKNOWN;
+ private boolean progressive;
+ private int format;
+ private InputStream in;
+ private DataInput din;
+ private boolean collectComments = true;
+ private Vector comments;
+ private boolean determineNumberOfImages;
+ private int numberOfImages;
+ private int physicalHeightDpi;
+ private int physicalWidthDpi;
+
+ private void addComment(String s) {
+ if (comments == null) {
+ comments = new Vector();
+ }
+ comments.addElement(s);
+ }
+
+ /**
+ * Call this method after you have provided an input stream or file
+ * using {@link #setInput(InputStream)} or {@link #setInput(DataInput)}.
+ * If true is returned, the file format was known and information
+ * on the file's content can be retrieved using the various getXyz methods.
+ * @return if information could be retrieved from input
+ */
+ public boolean check() {
+ format = -1;
+ width = -1;
+ height = -1;
+ bitsPerPixel = -1;
+ numberOfImages = 1;
+ physicalHeightDpi = -1;
+ physicalWidthDpi = -1;
+ comments = null;
+ try {
+ int b1 = read() & 0xff;
+ int b2 = read() & 0xff;
+ if (b1 == 0x47 && b2 == 0x49) {
+ return checkGif();
+ }
+ else
+ if (b1 == 0x89 && b2 == 0x50) {
+ return checkPng();
+ }
+ else
+ if (b1 == 0xff && b2 == 0xd8) {
+ return checkJpeg();
+ }
+ else
+ if (b1 == 0x42 && b2 == 0x4d) {
+ return checkBmp();
+ }
+ else
+ if (b1 == 0x0a && b2 < 0x06) {
+ return checkPcx();
+ }
+ else
+ if (b1 == 0x46 && b2 == 0x4f) {
+ return checkIff();
+ }
+ else
+ if (b1 == 0x59 && b2 == 0xa6) {
+ return checkRas();
+ }
+ else
+ if (b1 == 0x50 && b2 >= 0x31 && b2 <= 0x36) {
+ return checkPnm(b2 - '0');
+ }
+ else
+ if (b1 == 0x38 && b2 == 0x42) {
+ return checkPsd();
+ }
+ else {
+ return false;
+ }
+ } catch (IOException ioe) {
+ return false;
+ }
+ }
+
+ private boolean checkBmp() throws IOException {
+ byte[] a = new byte[44];
+ if (read(a) != a.length) {
+ return false;
+ }
+ width = getIntLittleEndian(a, 16);
+ height = getIntLittleEndian(a, 20);
+ if (width < 1 || height < 1) {
+ return false;
+ }
+ bitsPerPixel = getShortLittleEndian(a, 26);
+ if (bitsPerPixel != 1 && bitsPerPixel != 4 &&
+ bitsPerPixel != 8 && bitsPerPixel != 16 &&
+ bitsPerPixel != 24 && bitsPerPixel != 32) {
+ return false;
+ }
+ int x = (int)(getIntLittleEndian(a, 36) * 0.0254);
+ if (x > 0) {
+ setPhysicalWidthDpi(x);
+ }
+ int y = (int)(getIntLittleEndian(a, 40) * 0.0254);
+ if (y > 0) {
+ setPhysicalHeightDpi(y);
+ }
+ format = FORMAT_BMP;
+ return true;
+ }
+
+ private boolean checkGif() throws IOException {
+ final byte[] GIF_MAGIC_87A = {0x46, 0x38, 0x37, 0x61};
+ final byte[] GIF_MAGIC_89A = {0x46, 0x38, 0x39, 0x61};
+ byte[] a = new byte[11]; // 4 from the GIF signature + 7 from the global header
+ if (read(a) != 11) {
+ return false;
+ }
+ if ((!equals(a, 0, GIF_MAGIC_89A, 0, 4)) &&
+ (!equals(a, 0, GIF_MAGIC_87A, 0, 4))) {
+ return false;
+ }
+ format = FORMAT_GIF;
+ width = getShortLittleEndian(a, 4);
+ height = getShortLittleEndian(a, 6);
+ int flags = a[8] & 0xff;
+ bitsPerPixel = ((flags >> 4) & 0x07) + 1;
+ //progressive = (flags & 0x02) != 0;
+ if (!determineNumberOfImages) {
+ return true;
+ }
+ // skip global color palette
+ if ((flags & 0x80) != 0) {
+ int tableSize = (1 << ((flags & 7) + 1)) * 3;
+ skip(tableSize);
+ }
+ numberOfImages = 0;
+ int blockType;
+ do
+ {
+ blockType = read();
+ switch(blockType)
+ {
+ case(0x2c): // image separator
+ {
+ if (read(a, 0, 9) != 9) {
+ return false;
+ }
+ flags = a[8] & 0xff;
+ progressive = (flags & 0x40) != 0;
+ /*int locWidth = getShortLittleEndian(a, 4);
+ int locHeight = getShortLittleEndian(a, 6);
+ System.out.println("LOCAL: " + locWidth + " x " + locHeight);*/
+ int localBitsPerPixel = (flags & 0x07) + 1;
+ if (localBitsPerPixel > bitsPerPixel) {
+ bitsPerPixel = localBitsPerPixel;
+ }
+ if ((flags & 0x80) != 0) {
+ skip((1 << localBitsPerPixel) * 3);
+ }
+ skip(1); // initial code length
+ int n;
+ do
+ {
+ n = read();
+ if (n > 0) {
+ skip(n);
+ }
+ else
+ if (n == -1) {
+ return false;
+ }
+ }
+ while (n > 0);
+ numberOfImages++;
+ break;
+ }
+ case(0x21): // extension
+ {
+ int extensionType = read();
+ if (collectComments && extensionType == 0xfe) {
+ StringBuffer sb = new StringBuffer();
+ int n;
+ do
+ {
+ n = read();
+ if (n == -1) {
+ return false;
+ }
+ if (n > 0) {
+ for (int i = 0; i < n; i++) {
+ int ch = read();
+ if (ch == -1) {
+ return false;
+ }
+ sb.append((char)ch);
+ }
+ }
+ }
+ while (n > 0);
+ } else {
+ int n;
+ do
+ {
+ n = read();
+ if (n > 0) {
+ skip(n);
+ }
+ else
+ if (n == -1) {
+ return false;
+ }
+ }
+ while (n > 0);
+ }
+ break;
+ }
+ case(0x3b): // end of file
+ {
+ break;
+ }
+ default:
+ {
+ return false;
+ }
+ }
+ }
+ while (blockType != 0x3b);
+ return true;
+ }
+
+ private boolean checkIff() throws IOException {
+ byte[] a = new byte[10];
+ // read remaining 2 bytes of file id, 4 bytes file size
+ // and 4 bytes IFF subformat
+ if (read(a, 0, 10) != 10) {
+ return false;
+ }
+ final byte[] IFF_RM = {0x52, 0x4d};
+ if (!equals(a, 0, IFF_RM, 0, 2)) {
+ return false;
+ }
+ int type = getIntBigEndian(a, 6);
+ if (type != 0x494c424d && // type must be ILBM...
+ type != 0x50424d20) { // ...or PBM
+ return false;
+ }
+ // loop chunks to find BMHD chunk
+ do {
+ if (read(a, 0, 8) != 8) {
+ return false;
+ }
+ int chunkId = getIntBigEndian(a, 0);
+ int size = getIntBigEndian(a, 4);
+ if ((size & 1) == 1) {
+ size++;
+ }
+ if (chunkId == 0x424d4844) { // BMHD chunk
+ if (read(a, 0, 9) != 9) {
+ return false;
+ }
+ format = FORMAT_IFF;
+ width = getShortBigEndian(a, 0);
+ height = getShortBigEndian(a, 2);
+ bitsPerPixel = a[8] & 0xff;
+ return (width > 0 && height > 0 && bitsPerPixel > 0 && bitsPerPixel < 33);
+ } else {
+ skip(size);
+ }
+ } while (true);
+ }
+
+ private boolean checkJpeg() throws IOException {
+ byte[] data = new byte[12];
+ while (true) {
+ if (read(data, 0, 4) != 4) {
+ return false;
+ }
+ int marker = getShortBigEndian(data, 0);
+ int size = getShortBigEndian(data, 2);
+ if ((marker & 0xff00) != 0xff00) {
+ return false; // not a valid marker
+ }
+ if (marker == 0xffe0) { // APPx
+ if (size < 14) {
+ // not an APPx header as we know it, skip
+ skip(size - 2);
+ continue;
+ }
+ if (read(data, 0, 12) != 12) {
+ return false;
+ }
+ final byte[] APP0_ID = {0x4a, 0x46, 0x49, 0x46, 0x00};
+ if (equals(APP0_ID, 0, data, 0, 5)) {
+ //System.out.println("data 7=" + data[7]);
+ if (data[7] == 1) {
+ setPhysicalWidthDpi(getShortBigEndian(data, 8));
+ setPhysicalHeightDpi(getShortBigEndian(data, 10));
+ }
+ else
+ if (data[7] == 2) {
+ int x = getShortBigEndian(data, 8);
+ int y = getShortBigEndian(data, 10);
+ setPhysicalWidthDpi((int)(x * 2.54f));
+ setPhysicalHeightDpi((int)(y * 2.54f));
+ }
+ }
+ skip(size - 14);
+ }
+ else
+ if (collectComments && size > 2 && marker == 0xfffe) { // comment
+ size -= 2;
+ byte[] chars = new byte[size];
+ if (read(chars, 0, size) != size) {
+ return false;
+ }
+ String comment = new String(chars, "iso-8859-1");
+ comment = comment.trim();
+ addComment(comment);
+ }
+ else
+ if (marker >= 0xffc0 && marker <= 0xffcf && marker != 0xffc4 && marker != 0xffc8) {
+ if (read(data, 0, 6) != 6) {
+ return false;
+ }
+ format = FORMAT_JPEG;
+ bitsPerPixel = (data[0] & 0xff) * (data[5] & 0xff);
+ progressive = marker == 0xffc2 || marker == 0xffc6 ||
+ marker == 0xffca || marker == 0xffce;
+ width = getShortBigEndian(data, 3);
+ height = getShortBigEndian(data, 1);
+ return true;
+ } else {
+ skip(size - 2);
+ }
+ }
+ }
+
+ private boolean checkPcx() throws IOException {
+ byte[] a = new byte[64];
+ if (read(a) != a.length) {
+ return false;
+ }
+ if (a[0] != 1) { // encoding, 1=RLE is only valid value
+ return false;
+ }
+ // width / height
+ int x1 = getShortLittleEndian(a, 2);
+ int y1 = getShortLittleEndian(a, 4);
+ int x2 = getShortLittleEndian(a, 6);
+ int y2 = getShortLittleEndian(a, 8);
+ if (x1 < 0 || x2 < x1 || y1 < 0 || y2 < y1) {
+ return false;
+ }
+ width = x2 - x1 + 1;
+ height = y2 - y1 + 1;
+ // color depth
+ int bits = a[1];
+ int planes = a[63];
+ if (planes == 1 &&
+ (bits == 1 || bits == 2 || bits == 4 || bits == 8)) {
+ // paletted
+ bitsPerPixel = bits;
+ } else
+ if (planes == 3 && bits == 8) {
+ // RGB truecolor
+ bitsPerPixel = 24;
+ } else {
+ return false;
+ }
+ setPhysicalWidthDpi(getShortLittleEndian(a, 10));
+ setPhysicalHeightDpi(getShortLittleEndian(a, 10));
+ format = FORMAT_PCX;
+ return true;
+ }
+
+ private boolean checkPng() throws IOException {
+ final byte[] PNG_MAGIC = {0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a};
+ byte[] a = new byte[27];
+ if (read(a) != 27) {
+ return false;
+ }
+ if (!equals(a, 0, PNG_MAGIC, 0, 6)) {
+ return false;
+ }
+ format = FORMAT_PNG;
+ width = getIntBigEndian(a, 14);
+ height = getIntBigEndian(a, 18);
+ bitsPerPixel = a[22] & 0xff;
+ int colorType = a[23] & 0xff;
+ if (colorType == 2 || colorType == 6) {
+ bitsPerPixel *= 3;
+ }
+ progressive = (a[26] & 0xff) != 0;
+ return true;
+ }
+
+ private boolean checkPnm(int id) throws IOException {
+ if (id < 1 || id > 6) {
+ return false;
+ }
+ final int[] PNM_FORMATS = {FORMAT_PBM, FORMAT_PGM, FORMAT_PPM};
+ format = PNM_FORMATS[(id - 1) % 3];
+ boolean hasPixelResolution = false;
+ String s;
+ while (true)
+ {
+ s = readLine();
+ if (s != null) {
+ s = s.trim();
+ }
+ if (s == null || s.length() < 1) {
+ continue;
+ }
+ if (s.charAt(0) == '#') { // comment
+ if (collectComments && s.length() > 1) {
+ addComment(s.substring(1));
+ }
+ continue;
+ }
+ if (!hasPixelResolution) { // split "343 966" into width=343, height=966
+ int spaceIndex = s.indexOf(' ');
+ if (spaceIndex == -1) {
+ return false;
+ }
+ String widthString = s.substring(0, spaceIndex);
+ spaceIndex = s.lastIndexOf(' ');
+ if (spaceIndex == -1) {
+ return false;
+ }
+ String heightString = s.substring(spaceIndex + 1);
+ try {
+ width = Integer.parseInt(widthString);
+ height = Integer.parseInt(heightString);
+ } catch (NumberFormatException nfe) {
+ return false;
+ }
+ if (width < 1 || height < 1) {
+ return false;
+ }
+ if (format == FORMAT_PBM) {
+ bitsPerPixel = 1;
+ return true;
+ }
+ hasPixelResolution = true;
+ }
+ else
+ {
+ int maxSample;
+ try {
+ maxSample = Integer.parseInt(s);
+ } catch (NumberFormatException nfe) {
+ return false;
+ }
+ if (maxSample < 0) {
+ return false;
+ }
+ for (int i = 0; i < 25; i++) {
+ if (maxSample < (1 << (i + 1))) {
+ bitsPerPixel = i + 1;
+ if (format == FORMAT_PPM) {
+ bitsPerPixel *= 3;
+ }
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+ }
+
+ private boolean checkPsd() throws IOException {
+ byte[] a = new byte[24];
+ if (read(a) != a.length) {
+ return false;
+ }
+ final byte[] PSD_MAGIC = {0x50, 0x53};
+ if (!equals(a, 0, PSD_MAGIC, 0, 2)) {
+ return false;
+ }
+ format = FORMAT_PSD;
+ width = getIntBigEndian(a, 16);
+ height = getIntBigEndian(a, 12);
+ int channels = getShortBigEndian(a, 10);
+ int depth = getShortBigEndian(a, 20);
+ bitsPerPixel = channels * depth;
+ return (width > 0 && height > 0 && bitsPerPixel > 0 && bitsPerPixel <= 64);
+ }
+
+ private boolean checkRas() throws IOException {
+ byte[] a = new byte[14];
+ if (read(a) != a.length) {
+ return false;
+ }
+ final byte[] RAS_MAGIC = {0x6a, (byte)0x95};
+ if (!equals(a, 0, RAS_MAGIC, 0, 2)) {
+ return false;
+ }
+ format = FORMAT_RAS;
+ width = getIntBigEndian(a, 2);
+ height = getIntBigEndian(a, 6);
+ bitsPerPixel = getIntBigEndian(a, 10);
+ return (width > 0 && height > 0 && bitsPerPixel > 0 && bitsPerPixel <= 24);
+ }
+
+ /**
+ * Run over String list, return false iff at least one of the arguments
+ * equals true
as argument to identify animated GIFs
+ * ({@link #getNumberOfImages()} will return a value larger than 1
).-1
.
+ * -c
.
+ * @param args string list to check
+ */
+ private static boolean determineVerbosity(String[] args) {
+ if (args != null && args.length > 0) {
+ for (int i = 0; i < args.length; i++) {
+ if ("-c".equals(args[i])) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ private static boolean equals(byte[] a1, int offs1, byte[] a2, int offs2, int num) {
+ while (num-- > 0) {
+ if (a1[offs1++] != a2[offs2++]) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * If {@link #check()} was successful, returns the image's number of bits per pixel.
+ * Does not include transparency information like the alpha channel.
+ * @return number of bits per image pixel
+ */
+ public int getBitsPerPixel() {
+ return bitsPerPixel;
+ }
+
+ /**
+ * Returns the index'th comment retrieved from the file.
+ * @param index int index of comment to return
+ * @throws IllegalArgumentException if index is smaller than 0 or larger than or equal
+ * to the number of comments retrieved
+ * @see #getNumberOfComments
+ */
+ public String getComment(int index) {
+ if (comments == null || index < 0 || index >= comments.size()) {
+ throw new IllegalArgumentException("Not a valid comment index: " + index);
+ }
+ return (String)comments.elementAt(index);
+ }
+
+ /**
+ * If {@link #check()} was successful, returns the image format as one
+ * of the FORMAT_xyz constants from this class.
+ * Use {@link #getFormatName()} to get a textual description of the file format.
+ * @return file format as a FORMAT_xyz constant
+ */
+ public int getFormat() {
+ return format;
+ }
+
+ /**
+ * If {@link #check()} was successful, returns the image format's name.
+ * Use {@link #getFormat()} to get a unique number.
+ * @return file format name
+ */
+ public String getFormatName() {
+ if (format >= 0 && format < FORMAT_NAMES.length) {
+ return FORMAT_NAMES[format];
+ } else {
+ return "?";
+ }
+ }
+
+ /**
+ * If {@link #check()} was successful, returns one the image's vertical
+ * resolution in pixels.
+ * @return image height in pixels
+ */
+ public int getHeight() {
+ return height;
+ }
+
+ private static int getIntBigEndian(byte[] a, int offs) {
+ return
+ (a[offs] & 0xff) << 24 |
+ (a[offs + 1] & 0xff) << 16 |
+ (a[offs + 2] & 0xff) << 8 |
+ a[offs + 3] & 0xff;
+ }
+
+ private static int getIntLittleEndian(byte[] a, int offs) {
+ return
+ (a[offs + 3] & 0xff) << 24 |
+ (a[offs + 2] & 0xff) << 16 |
+ (a[offs + 1] & 0xff) << 8 |
+ a[offs] & 0xff;
+ }
+
+ /**
+ * If {@link #check()} was successful, returns a String with the
+ * MIME type of the format.
+ * @return MIME type, e.g. image/jpeg
+ */
+ public String getMimeType() {
+ if (format >= 0 && format < MIME_TYPE_STRINGS.length) {
+ if (format == FORMAT_JPEG && progressive)
+ {
+ return "image/pjpeg";
+ }
+ return MIME_TYPE_STRINGS[format];
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * If {@link #check()} was successful and {@link #setCollectComments(boolean)} was called with
+ * true
as argument, returns the number of comments retrieved
+ * from the input image stream / file.
+ * Any number >= 0 and smaller than this number of comments is then a
+ * valid argument for the {@link #getComment(int)} method.
+ * @return number of comments retrieved from input image
+ */
+ public int getNumberOfComments()
+ {
+ if (comments == null) {
+ return 0;
+ } else {
+ return comments.size();
+ }
+ }
+
+ /**
+ * Returns the number of images in the examined file.
+ * Assumes that setDetermineImageNumber(true);
was called before
+ * a successful call to {@link #check()}.
+ * This value can currently be only different from 1
for GIF images.
+ * @return number of images in file
+ */
+ public int getNumberOfImages()
+ {
+ return numberOfImages;
+ }
+
+ /**
+ * Returns the physical height of this image in dots per inch (dpi).
+ * Assumes that {@link #check()} was successful.
+ * Returns -1
on failure.
+ * @return physical height (in dpi)
+ * @see #getPhysicalWidthDpi()
+ * @see #getPhysicalHeightInch()
+ */
+ public int getPhysicalHeightDpi() {
+ return physicalHeightDpi;
+ }
+
+ /**
+ * If {@link #check()} was successful, returns the physical width of this image in dpi (dots per inch)
+ * or -1 if no value could be found.
+ * @return physical height (in dpi)
+ * @see #getPhysicalHeightDpi()
+ * @see #getPhysicalWidthDpi()
+ * @see #getPhysicalWidthInch()
+ */
+ public float getPhysicalHeightInch() {
+ int h = getHeight();
+ int ph = getPhysicalHeightDpi();
+ if (h > 0 && ph > 0) {
+ return ((float)h) / ((float)ph);
+ } else {
+ return -1.0f;
+ }
+ }
+
+ /**
+ * If {@link #check()} was successful, returns the physical width of this image in dpi (dots per inch)
+ * or -1 if no value could be found.
+ * @return physical width (in dpi)
+ * @see #getPhysicalHeightDpi()
+ * @see #getPhysicalWidthInch()
+ * @see #getPhysicalHeightInch()
+ */
+ public int getPhysicalWidthDpi() {
+ return physicalWidthDpi;
+ }
+
+ /**
+ * Returns the physical width of an image in inches, or
+ * -1.0f
if width information is not available.
+ * Assumes that {@link #check} has been called successfully.
+ * @return physical width in inches or -1.0f
on failure
+ * @see #getPhysicalWidthDpi
+ * @see #getPhysicalHeightInch
+ */
+ public float getPhysicalWidthInch() {
+ int w = getWidth();
+ int pw = getPhysicalWidthDpi();
+ if (w > 0 && pw > 0) {
+ return ((float)w) / ((float)pw);
+ } else {
+ return -1.0f;
+ }
+ }
+
+ private static int getShortBigEndian(byte[] a, int offs) {
+ return
+ (a[offs] & 0xff) << 8 |
+ (a[offs + 1] & 0xff);
+ }
+
+ private static int getShortLittleEndian(byte[] a, int offs) {
+ return (a[offs] & 0xff) | (a[offs + 1] & 0xff) << 8;
+ }
+
+ /**
+ * If {@link #check()} was successful, returns one the image's horizontal
+ * resolution in pixels.
+ * @return image width in pixels
+ */
+ public int getWidth() {
+ return width;
+ }
+
+ /**
+ * Returns whether the image is stored in a progressive (also called: interlaced) way.
+ * @return true for progressive/interlaced, false otherwise
+ */
+ public boolean isProgressive()
+ {
+ return progressive;
+ }
+
+ /**
+ * To use this class as a command line application, give it either
+ * some file names as parameters (information on them will be
+ * printed to standard output, one line per file) or call
+ * it with no parameters. It will then check data given to it
+ * via standard input.
+ * @param args the program arguments which must be file names
+ */
+ public static void main(String[] args) {
+ ImageInfo imageInfo = new ImageInfo();
+ imageInfo.setDetermineImageNumber(true);
+ boolean verbose = determineVerbosity(args);
+ if (args.length == 0) {
+ run(null, System.in, imageInfo, verbose);
+ } else {
+ int index = 0;
+ while (index < args.length) {
+ InputStream in = null;
+ try {
+ String name = args[index++];
+ System.out.print(name + ";");
+ if (name.startsWith("http://")) {
+ in = new URL(name).openConnection().getInputStream();
+ } else {
+ in = new FileInputStream(name);
+ }
+ run(name, in, imageInfo, verbose);
+ in.close();
+ } catch (IOException e) {
+ System.out.println(e);
+ try {
+ if (in != null) {
+ in.close();
+ }
+ } catch (IOException ee) {
+ }
+ }
+ }
+ }
+ }
+
+ private static void print(String sourceName, ImageInfo ii, boolean verbose) {
+ if (verbose) {
+ printVerbose(sourceName, ii);
+ } else {
+ printCompact(sourceName, ii);
+ }
+ }
+
+ private static void printCompact(String sourceName, ImageInfo imageInfo) {
+ final String SEP = "\t";
+ System.out.println(
+ sourceName + SEP +
+ imageInfo.getFormatName() + SEP +
+ imageInfo.getMimeType() + SEP +
+ imageInfo.getWidth() + SEP +
+ imageInfo.getHeight() + SEP +
+ imageInfo.getBitsPerPixel() + SEP +
+ imageInfo.getNumberOfImages() + SEP +
+ imageInfo.getPhysicalWidthDpi() + SEP +
+ imageInfo.getPhysicalHeightDpi() + SEP +
+ imageInfo.getPhysicalWidthInch() + SEP +
+ imageInfo.getPhysicalHeightInch() + SEP +
+ imageInfo.isProgressive()
+ );
+ }
+
+ private static void printLine(int indentLevels, String text, float value, float minValidValue) {
+ if (value < minValidValue) {
+ return;
+ }
+ printLine(indentLevels, text, Float.toString(value));
+ }
+
+ private static void printLine(int indentLevels, String text, int value, int minValidValue) {
+ if (value >= minValidValue) {
+ printLine(indentLevels, text, Integer.toString(value));
+ }
+ }
+
+ private static void printLine(int indentLevels, String text, String value) {
+ if (value == null || value.length() == 0) {
+ return;
+ }
+ while (indentLevels-- > 0) {
+ System.out.print("\t");
+ }
+ if (text != null && text.length() > 0) {
+ System.out.print(text);
+ System.out.print(" ");
+ }
+ System.out.println(value);
+ }
+
+ private static void printVerbose(String sourceName, ImageInfo ii) {
+ printLine(0, null, sourceName);
+ printLine(1, "File format: ", ii.getFormatName());
+ printLine(1, "MIME type: ", ii.getMimeType());
+ printLine(1, "Width (pixels): ", ii.getWidth(), 1);
+ printLine(1, "Height (pixels): ", ii.getHeight(), 1);
+ printLine(1, "Bits per pixel: ", ii.getBitsPerPixel(), 1);
+ printLine(1, "Progressive: ", ii.isProgressive() ? "yes" : "no");
+ printLine(1, "Number of images: ", ii.getNumberOfImages(), 1);
+ printLine(1, "Physical width (dpi): ", ii.getPhysicalWidthDpi(), 1);
+ printLine(1, "Physical height (dpi): ", ii.getPhysicalHeightDpi(), 1);
+ printLine(1, "Physical width (inches): ", ii.getPhysicalWidthInch(), 1.0f);
+ printLine(1, "Physical height (inches): ", ii.getPhysicalHeightInch(), 1.0f);
+ int numComments = ii.getNumberOfComments();
+ printLine(1, "Number of textual comments: ", numComments, 1);
+ if (numComments > 0) {
+ for (int i = 0; i < numComments; i++) {
+ printLine(2, null, ii.getComment(i));
+ }
+ }
+ }
+
+ private int read() throws IOException {
+ if (in != null) {
+ return in.read();
+ } else {
+ return din.readByte();
+ }
+ }
+
+ private int read(byte[] a) throws IOException {
+ if (in != null) {
+ return in.read(a);
+ } else {
+ din.readFully(a);
+ return a.length;
+ }
+ }
+
+ private int read(byte[] a, int offset, int num) throws IOException {
+ if (in != null) {
+ return in.read(a, offset, num);
+ } else {
+ din.readFully(a, offset, num);
+ return num;
+ }
+ }
+
+ private String readLine() throws IOException {
+ return readLine(new StringBuffer());
+ }
+
+ private String readLine(StringBuffer sb) throws IOException {
+ boolean finished;
+ do {
+ int value = read();
+ finished = (value == -1 || value == 10);
+ if (!finished) {
+ sb.append((char)value);
+ }
+ } while (!finished);
+ return sb.toString();
+ }
+
+ private static void run(String sourceName, InputStream in, ImageInfo imageInfo, boolean verbose) {
+ imageInfo.setInput(in);
+ imageInfo.setDetermineImageNumber(true);
+ imageInfo.setCollectComments(verbose);
+ if (imageInfo.check()) {
+ print(sourceName, imageInfo, verbose);
+ }
+ }
+
+ /**
+ * Specify whether textual comments are supposed to be extracted from input.
+ * Default is false
.
+ * If enabled, comments will be added to an internal list.
+ * @param newValue if true
, this class will read comments
+ * @see #getNumberOfComments
+ * @see #getComment
+ */
+ public void setCollectComments(boolean newValue)
+ {
+ collectComments = newValue;
+ }
+
+ /**
+ * Specify whether the number of images in a file is to be
+ * determined - default is false
.
+ * This is a special option because some file formats require running over
+ * the entire file to find out the number of images, a rather time-consuming
+ * task.
+ * Not all file formats support more than one image.
+ * If this method is called with true
as argument,
+ * the actual number of images can be queried via
+ * {@link #getNumberOfImages()} after a successful call to
+ * {@link #check()}.
+ * @param newValue will the number of images be determined?
+ * @see #getNumberOfImages
+ */
+ public void setDetermineImageNumber(boolean newValue)
+ {
+ determineNumberOfImages = newValue;
+ }
+
+ /**
+ * Set the input stream to the argument stream (or file).
+ * Note that {@link java.io.RandomAccessFile} implements
+ * {@link java.io.DataInput}.
+ * @param dataInput the input stream to read from
+ */
+ public void setInput(DataInput dataInput) {
+ din = dataInput;
+ in = null;
+ }
+
+ /**
+ * Set the input stream to the argument stream (or file).
+ * @param inputStream the input stream to read from
+ */
+ public void setInput(InputStream inputStream) {
+ in = inputStream;
+ din = null;
+ }
+
+ private void setPhysicalHeightDpi(int newValue) {
+ physicalWidthDpi = newValue;
+ }
+
+ private void setPhysicalWidthDpi(int newValue) {
+ physicalHeightDpi = newValue;
+ }
+
+ private void skip(int num) throws IOException {
+ while (num > 0) {
+ long result;
+ if (in != null) {
+ result = in.skip(num);
+ } else {
+ result = din.skipBytes(num);
+ }
+ if (result > 0) {
+ num -= result;
+ } else {
+ if (in != null) {
+ result = in.read();
+ } else {
+ result = din.readByte();
+ }
+ if (result == -1) {
+ throw new IOException("Premature end of input.");
+ } else {
+ num--;
+ }
+ }
+ }
+ }
+}
Index: /FCKeditor.Java/tags/2.4/java-core/src/main/javadoc/net/fckeditor/connector/package.html
===================================================================
--- /FCKeditor.Java/tags/2.4/java-core/src/main/javadoc/net/fckeditor/connector/package.html (revision 2194)
+++ /FCKeditor.Java/tags/2.4/java-core/src/main/javadoc/net/fckeditor/connector/package.html (revision 2194)
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+Connector used by the FCKeditor to list and create resources on the server.
+
+Related Documentation
+
+For overviews, tutorials, examples, guides, and tool documentation, please see:
+
+
+
+
+
+
+
Index: /FCKeditor.Java/tags/2.4/java-core/src/main/javadoc/net/fckeditor/handlers/package.html
===================================================================
--- /FCKeditor.Java/tags/2.4/java-core/src/main/javadoc/net/fckeditor/handlers/package.html (revision 2194)
+++ /FCKeditor.Java/tags/2.4/java-core/src/main/javadoc/net/fckeditor/handlers/package.html (revision 2194)
@@ -0,0 +1,97 @@
+
+
+
+
+
+
+
+Different handlers for various purposes used in the entire system.
+
+
+
+
+
+
+
+
+
+
+
+
+Different handlers for various purposes used in the entire system.
+
+
+
+
+
+
+
+
+
+
+
+
+Different handlers for various purposes used in the entire system.
+
+
+
+
+
Index: /FCKeditor.Java/tags/2.4/java-core/src/main/javadoc/net/fckeditor/package.html
===================================================================
--- /FCKeditor.Java/tags/2.4/java-core/src/main/javadoc/net/fckeditor/package.html (revision 2194)
+++ /FCKeditor.Java/tags/2.4/java-core/src/main/javadoc/net/fckeditor/package.html (revision 2194)
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+Core objects to manage the FCKeditor text input form.
+
+Related Documentation
+
+For overviews, tutorials, examples, guides, and tool documentation, please see:
+
+
+
+
+
+
Index: /FCKeditor.Java/tags/2.4/java-core/src/main/javadoc/net/fckeditor/requestcycle/impl/package.html
===================================================================
--- /FCKeditor.Java/tags/2.4/java-core/src/main/javadoc/net/fckeditor/requestcycle/impl/package.html (revision 2194)
+++ /FCKeditor.Java/tags/2.4/java-core/src/main/javadoc/net/fckeditor/requestcycle/impl/package.html (revision 2194)
@@ -0,0 +1,97 @@
+
+
+
+
+
+
+
+Basic/pre-defined implementations for the request cycle interfaces.
+
+
+
+
+
+
+
+
+
+
+
+
+Basic/pre-defined implementations for the request cycle interfaces.
+
+
+
+
+
+
+
+
+
+
+
+
+Basic/pre-defined implementations for the request cycle interfaces.
+
+
+
+
+
Index: /FCKeditor.Java/tags/2.4/java-core/src/main/javadoc/net/fckeditor/requestcycle/package.html
===================================================================
--- /FCKeditor.Java/tags/2.4/java-core/src/main/javadoc/net/fckeditor/requestcycle/package.html (revision 2194)
+++ /FCKeditor.Java/tags/2.4/java-core/src/main/javadoc/net/fckeditor/requestcycle/package.html (revision 2194)
@@ -0,0 +1,97 @@
+
+
+
+
+
+
+
+Interfaces for the request life cycle.
+
+
+
+
+
+
+
+
+
+
+
+
+Interfaces for the request life cycle.
+
+
+
+
+
+
+
+
+
+
+
+
+Interfaces for the request life cycle.
+
+
+
+
+
Index: /FCKeditor.Java/tags/2.4/java-core/src/main/javadoc/net/fckeditor/response/package.html
===================================================================
--- /FCKeditor.Java/tags/2.4/java-core/src/main/javadoc/net/fckeditor/response/package.html (revision 2194)
+++ /FCKeditor.Java/tags/2.4/java-core/src/main/javadoc/net/fckeditor/response/package.html (revision 2194)
@@ -0,0 +1,97 @@
+
+
+
+
+
+
+
+Response object wrappers for GET
and POST
requests.
+
+
+
+
+
+
+
+
+
+
+
+
+Response object wrappers for GET
and POST
requests.
+
+
+
+
+
+
+
+
+
+
+
+
+Response object wrappers for GET
and POST
requests.
+
+
+
+
+
Index: /FCKeditor.Java/tags/2.4/java-core/src/main/javadoc/net/fckeditor/tags/package.html
===================================================================
--- /FCKeditor.Java/tags/2.4/java-core/src/main/javadoc/net/fckeditor/tags/package.html (revision 2194)
+++ /FCKeditor.Java/tags/2.4/java-core/src/main/javadoc/net/fckeditor/tags/package.html (revision 2194)
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+JSP tags to access and modify the FCKeditor object.
+
+Related Documentation
+
+For overviews, tutorials, examples, guides, and tool documentation, please see:
+
+
+
+
+
+
+
Index: /FCKeditor.Java/tags/2.4/java-core/src/main/javadoc/net/fckeditor/tool/package.html
===================================================================
--- /FCKeditor.Java/tags/2.4/java-core/src/main/javadoc/net/fckeditor/tool/package.html (revision 2194)
+++ /FCKeditor.Java/tags/2.4/java-core/src/main/javadoc/net/fckeditor/tool/package.html (revision 2194)
@@ -0,0 +1,97 @@
+
+
+
+
+
+
+
+Various tool classes.
+
+
+
+
+
+
+
+
+
+
+
+
+Various tool classes.
+
+
+
+
+
+
+
+
+
+
+
+
+Various tool classes.
+
+
+
+
+
Index: /FCKeditor.Java/tags/2.4/java-core/src/main/javadoc/org/devlib/schmidt/imageinfo/package.html
===================================================================
--- /FCKeditor.Java/tags/2.4/java-core/src/main/javadoc/org/devlib/schmidt/imageinfo/package.html (revision 2194)
+++ /FCKeditor.Java/tags/2.4/java-core/src/main/javadoc/org/devlib/schmidt/imageinfo/package.html (revision 2194)
@@ -0,0 +1,102 @@
+
+
+
+
+
+
+
+External image information application. See
+ImageInfo
+for more information.
+
+
+
+
+
+
+
+
+
+
+
+
+External image information application. See
+ImageInfo
+for more information.
+
+
+
+
+
+
+
+
+
+
+
+
+External image information application. See
+ImageInfo
+for more information.
+
+
+
+
+
Index: /FCKeditor.Java/tags/2.4/java-core/src/main/resources/META-INF/FCKeditor.tld
===================================================================
--- /FCKeditor.Java/tags/2.4/java-core/src/main/resources/META-INF/FCKeditor.tld (revision 2194)
+++ /FCKeditor.Java/tags/2.4/java-core/src/main/resources/META-INF/FCKeditor.tld (revision 2194)
@@ -0,0 +1,128 @@
+
+
+ * User-Agent-Strings are taken from: http://www.useragentstring.com/pages/useragentstring.php
+ *
+ * @version $Id$
+ */
+public class CompatibilityTest {
+
+ @Test
+ public void testIE4Win() throws Exception {
+ assertFalse(Compatibility.check("Mozilla/4.0 (compatible; MSIE 4.01; Windows NT 5.0)"));
+ }
+
+ @Test
+ public void testIE522Mac() throws Exception {
+ assertFalse(Compatibility.check("Mozilla/4.0 (compatible; MSIE 5.22; Mac_PowerPC)"));
+ }
+
+ @Test
+ public void testIE55Win98() throws Exception {
+ assertTrue(Compatibility.check("Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)"));
+ }
+
+ @Test
+ public void testIE60WinNT() throws Exception {
+ assertTrue(Compatibility.check("Mozilla/4.0 (compatible; MSIE 6.0; MSIE 5.5; Windows NT 5.1)"));
+ }
+
+ @Test
+ public void testIE70WinVista() throws Exception {
+ assertTrue(Compatibility.check("Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0;)"));
+ }
+
+ @Test
+ public void testIE70bWinVista() throws Exception {
+ assertTrue(Compatibility.check("Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 6.0)"));
+ }
+
+ @Test
+ public void testSafari204OSX() throws Exception {
+ assertFalse(Compatibility.check("Mozilla/5.0 (Macintosh; U; PPC Mac OS X; sv-se) AppleWebKit/419 (KHTML, like Gecko) Safari/419.3"));
+ }
+
+ @Test
+ public void testSafari30WinXP() throws Exception {
+ assertTrue(Compatibility.check("Mozilla/5.0 (Windows; U; Windows NT 5.2; pt) AppleWebKit/522.11.3 (KHTML, like Gecko) Version/3.0 Safari/522.11.3"));
+ }
+
+ @Test
+ public void testSafari302OSX() throws Exception {
+ assertTrue(Compatibility.check("Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en) AppleWebKit/522+ (KHTML, like Gecko) Version/3.0.2 Safari/522.12"));
+ }
+
+ @Test
+ public void testSafari31OSX() throws Exception {
+ assertTrue(Compatibility.check("Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_2; en-au) AppleWebKit/525.8+ (KHTML, like Gecko) Version/3.1 Safari/525.6"));
+ }
+
+ @Test
+ public void testFirefox200112OSX() throws Exception {
+ assertTrue(Compatibility.check("Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12"));
+ }
+
+ @Test
+ public void testFirefox30Linux() throws Exception {
+ assertTrue(Compatibility.check("Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9pre) Gecko/2008040318 Firefox/3.0pre (Swiftfox)"));
+ }
+
+ @Test
+ public void testFirefox1509LinuxDebian() throws Exception {
+ assertTrue(Compatibility.check("Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/1.5.0.9 (Debian-2.0.0.9-2)"));
+ }
+
+ @Test
+ public void testOper925Win2k() throws Exception {
+ assertFalse(Compatibility.check("Opera/9.25 (Windows NT 5.0; U; en)"));
+ }
+
+ @Test
+ public void testOpera854WinNT() throws Exception {
+ assertFalse(Compatibility.check("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; de) Opera 8.54"));
+ }
+
+ @Test
+ public void testOpera95OSX() throws Exception {
+ assertTrue(Compatibility.check("Opera/9.50 (Macintosh; Intel Mac OS X; U; en)"));
+ }
+
+ @Test
+ public void testOpera95WinVista() throws Exception {
+ assertTrue(Compatibility.check("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 6.0; en) Opera 9.50"));
+ }
+
+ @Test
+ public void testEpaphany220Linux() throws Exception {
+ assertTrue(Compatibility.check("Mozilla/5.0 (X11; U; Linux i686; en; rv:1.9b3) Gecko Epiphany/2.20"));
+ }
+}
Index: /FCKeditor.Java/tags/2.4/java-core/src/test/java/net/fckeditor/tool/UtilsFileTest.java
===================================================================
--- /FCKeditor.Java/tags/2.4/java-core/src/test/java/net/fckeditor/tool/UtilsFileTest.java (revision 2194)
+++ /FCKeditor.Java/tags/2.4/java-core/src/test/java/net/fckeditor/tool/UtilsFileTest.java (revision 2194)
@@ -0,0 +1,199 @@
+/*
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ * - GNU General Public License Version 2 or later (the "GPL")
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * - Mozilla Public License Version 1.1 or later (the "MPL")
+ * http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ */
+package net.fckeditor.tool;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+
+/**
+ * Tests for {@link UtilsFile}.
+ *
+ * @version $Id$
+ */
+public class UtilsFileTest {
+
+ @Test
+ public void isSingleExtension01() {
+ boolean condition = UtilsFile.isSingleExtension("hacked.txt");
+ assertTrue(condition);
+ }
+
+ @Test
+ public void isSingleExtension02() {
+ boolean condition = UtilsFile.isSingleExtension("hacked.php_txt");
+ assertTrue(condition);
+ }
+
+ @Test
+ public void isSingleExtension03() {
+ boolean condition = UtilsFile.isSingleExtension("hacked.php.txt");
+ assertFalse(condition);
+ }
+
+ @Test
+ public void isSingleExtension04() {
+ boolean condition = UtilsFile.isSingleExtension("hacked.txt.");
+ assertFalse(condition);
+ }
+
+ @Test
+ public void isSingleExtension05() {
+ boolean condition = UtilsFile.isSingleExtension("hacked..txt");
+ assertFalse(condition);
+ }
+
+ @Test
+ public void forceSingleExtension01() {
+ String actual = UtilsFile.forceSingleExtension("hacked.txt");
+ assertEquals("hacked.txt", actual);
+ }
+
+ @Test
+ public void forceSingleExtension02() {
+ String actual = UtilsFile.forceSingleExtension("hacked.php_txt");
+ assertEquals("hacked.php_txt", actual);
+ }
+
+ @Test
+ public void forceSingleExtension03() {
+ String actual = UtilsFile.forceSingleExtension("hacked.php.txt");
+ assertEquals("hacked_php.txt", actual);
+ }
+
+ @Test
+ public void forceSingleExtension04() {
+ String actual = UtilsFile.forceSingleExtension("hacked..txt");
+ assertEquals("hacked_.txt", actual);
+ }
+
+ @Test
+ public void isValidPath01() {
+ String path = "";
+ boolean condition = UtilsFile.isValidPath(path);
+ assertFalse(condition);
+ }
+
+ @Test
+ public void isValidPath02() {
+ String path = "/";
+ boolean condition = UtilsFile.isValidPath(path);
+ assertTrue(condition);
+ }
+
+ @Test
+ public void isValidPath03() {
+ String path = "/./";
+ boolean condition = UtilsFile.isValidPath(path);
+ assertFalse(condition);
+ }
+
+ @Test
+ public void isValidPath04() {
+ String path = "/newf/..";
+ boolean condition = UtilsFile.isValidPath(path);
+ assertFalse(condition);
+ }
+
+ @Test
+ public void isValidPath05() {
+ String path = "/../";
+ boolean condition = UtilsFile.isValidPath(path);
+ assertFalse(condition);
+ }
+
+ @Test
+ public void isValidPath06() {
+ String path = "/stuff/../..";
+ boolean condition = UtilsFile.isValidPath(path);
+ assertFalse(condition);
+ }
+
+ @Test
+ public void isValidPath07() {
+ String path = "/my/stuff/../";
+ boolean condition = UtilsFile.isValidPath(path);
+ assertFalse(condition);
+ }
+
+ @Test
+ public void isValidPath08() {
+ String path = "/my/stuff/";
+ boolean condition = UtilsFile.isValidPath(path);
+ assertTrue(condition);
+ }
+
+ @Test
+ public void isValidPath09() {
+ String path = "/my/stuff";
+ boolean condition = UtilsFile.isValidPath(path);
+ assertFalse(condition);
+ }
+
+ @Test
+ public void isValidPath10() {
+ String path = "my/stuff/";
+ boolean condition = UtilsFile.isValidPath(path);
+ assertFalse(condition);
+ }
+
+ @Test
+ public void isValidPath11() {
+ String path = "/some/pa\\th/";
+ boolean condition = UtilsFile.isValidPath(path);
+ assertFalse(condition);
+ }
+
+ @Test
+ public void isValidPath12() {
+ String path = "/\\/";
+ boolean condition = UtilsFile.isValidPath(path);
+ assertFalse(condition);
+ }
+
+ @Test
+ public void sanitizeFolder01() {
+ assertEquals("a_b_c_d_e_f_g_h_i_", UtilsFile.sanitizeFolderName("a.b|cFCKeditor - JSP - Sample 1
+
+
+
+
+
+
Index: /FCKeditor.Java/tags/2.4/java-demo/src/main/webapp/jsp/sample02.jsp
===================================================================
--- /FCKeditor.Java/tags/2.4/java-demo/src/main/webapp/jsp/sample02.jsp (revision 2194)
+++ /FCKeditor.Java/tags/2.4/java-demo/src/main/webapp/jsp/sample02.jsp (revision 2194)
@@ -0,0 +1,61 @@
+
+<%@ page language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8" %>
+<%@ taglib uri="http://java.fckeditor.net" prefix="FCK" %>
+<%--
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ * - GNU General Public License Version 2 or later (the "GPL")
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * - Mozilla Public License Version 1.1 or later (the "MPL")
+ * http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ * @version: $Id$
+--%>
+
+
+
+ FCKeditor - JSP - Sample 2
+ This sample displays a normal HTML form with an FCKeditor with full
+ features enabled.
+ This sample uses the FCKeditor Taglib: this method is preferred to
+ the API version
+ All other sample pages will use this method.
+
+
+
+
Index: /FCKeditor.Java/tags/2.4/java-demo/src/main/webapp/jsp/sample03.jsp
===================================================================
--- /FCKeditor.Java/tags/2.4/java-demo/src/main/webapp/jsp/sample03.jsp (revision 2194)
+++ /FCKeditor.Java/tags/2.4/java-demo/src/main/webapp/jsp/sample03.jsp (revision 2194)
@@ -0,0 +1,95 @@
+
+<%@ page language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8" %>
+<%@ taglib uri="http://java.fckeditor.net" prefix="FCK" %>
+<%--
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ * - GNU General Public License Version 2 or later (the "GPL")
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * - Mozilla Public License Version 1.1 or later (the "MPL")
+ * http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ * @version: $Id$
+--%>
+
+
+
+ FCKeditor - JSP - Sample 3
+ This sample shows the editor in all it's available languages.
+ The Language dropdown is populated with JavaScript API.
+
+
+
+
+
+
+ Select a language:
+
+
+
+
+
+
+
+
Index: /FCKeditor.Java/tags/2.4/java-demo/src/main/webapp/jsp/sample04.jsp
===================================================================
--- /FCKeditor.Java/tags/2.4/java-demo/src/main/webapp/jsp/sample04.jsp (revision 2194)
+++ /FCKeditor.Java/tags/2.4/java-demo/src/main/webapp/jsp/sample04.jsp (revision 2194)
@@ -0,0 +1,77 @@
+
+<%@ page language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8" %>
+<%@ taglib uri="http://java.fckeditor.net" prefix="FCK" %>
+<%--
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ * - GNU General Public License Version 2 or later (the "GPL")
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * - Mozilla Public License Version 1.1 or later (the "MPL")
+ * http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ * @version: $Id$
+--%>
+
+
+
+ FCKeditor - JSP - Sample 4
+ This sample shows how to change the editor toolbar.
+
+
+
+
+
+
+ Select the toolbar to load:
+
+
+
+
+
+
+
+
Index: /FCKeditor.Java/tags/2.4/java-demo/src/main/webapp/jsp/sample05.jsp
===================================================================
--- /FCKeditor.Java/tags/2.4/java-demo/src/main/webapp/jsp/sample05.jsp (revision 2194)
+++ /FCKeditor.Java/tags/2.4/java-demo/src/main/webapp/jsp/sample05.jsp (revision 2194)
@@ -0,0 +1,92 @@
+
+<%@ page language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8" %>
+<%@ taglib uri="http://java.fckeditor.net" prefix="FCK" %>
+<%--
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ * - GNU General Public License Version 2 or later (the "GPL")
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * - Mozilla Public License Version 1.1 or later (the "MPL")
+ * http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ * @version: $Id$
+--%>
+
+
+
+ FCKeditor - JSP - Sample 5
+ This sample shows how to change the editor skin.
+
+
+
+
+
+
+ Select the skin to load:
+
+
+
+
+
+
+
+
Index: /FCKeditor.Java/tags/2.4/java-demo/src/main/webapp/jsp/sample06.config.js
===================================================================
--- /FCKeditor.Java/tags/2.4/java-demo/src/main/webapp/jsp/sample06.config.js (revision 2194)
+++ /FCKeditor.Java/tags/2.4/java-demo/src/main/webapp/jsp/sample06.config.js (revision 2194)
@@ -0,0 +1,43 @@
+/*
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ * - GNU General Public License Version 2 or later (the "GPL")
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * - Mozilla Public License Version 1.1 or later (the "MPL")
+ * http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ * @version: $Id$
+ */
+
+// Set our sample toolbar.
+FCKConfig.ToolbarSets['PluginTest'] = [
+ ['Source'],
+ ['My_Find','My_Replace','-','Placeholder'],
+ //['Table','-','TableInsertRow','TableDeleteRows','TableInsertColumn','TableDeleteColumns','TableInsertCell','TableDeleteCells','TableMergeCells','TableSplitCell'],
+ ['Bold','Italic','-','OrderedList','UnorderedList','-','Link','Unlink','-','About']
+] ;
+
+// Change the default plugin path.
+FCKConfig.PluginsPath = FCKConfig.BasePath.substr(0, FCKConfig.BasePath.length - 7) + '_samples/_plugins/' ;
+
+// Add our plugin to the plugins list.
+// FCKConfig.Plugins.Add( pluginName, availableLanguages )
+// pluginName: The plugin name. The plugin directory must match this name.
+// availableLanguages: a list of available language files for the plugin (separated by a comma).
+FCKConfig.Plugins.Add( 'findreplace', 'en,it' ) ;
+
+// If you want to use plugins found on other directories, just use the third parameter.
+var sOtherPluginPath = FCKConfig.BasePath.substr(0, FCKConfig.BasePath.length - 7) + 'editor/plugins/' ;
+FCKConfig.Plugins.Add( 'placeholder', 'en,it', sOtherPluginPath ) ;
+//FCKConfig.Plugins.Add( 'tablecommands', 'en,it', sOtherPluginPath ) ;
Index: /FCKeditor.Java/tags/2.4/java-demo/src/main/webapp/jsp/sample06.jsp
===================================================================
--- /FCKeditor.Java/tags/2.4/java-demo/src/main/webapp/jsp/sample06.jsp (revision 2194)
+++ /FCKeditor.Java/tags/2.4/java-demo/src/main/webapp/jsp/sample06.jsp (revision 2194)
@@ -0,0 +1,66 @@
+
+<%@ page language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8" %>
+<%@ taglib uri="http://java.fckeditor.net" prefix="FCK" %>
+<%--
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ * - GNU General Public License Version 2 or later (the "GPL")
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * - Mozilla Public License Version 1.1 or later (the "MPL")
+ * http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ * @version: $Id$
+--%>
+
+
+
+ FCKeditor - JSP - Sample 6
+ This sample shows a sample plugin implementation.
+
+ These are sample "Find" and "Replace" plugin that do exactly the same
+ thing that the built in ones do. Use the green toolbar buttons the test then.
+
+ There is also another sample plugin that is available in the package:
+ the "Placeholder" command (use the yellow icon).
+
+
+
+
Index: /FCKeditor.Java/tags/2.4/java-demo/src/main/webapp/jsp/sample07.jsp
===================================================================
--- /FCKeditor.Java/tags/2.4/java-demo/src/main/webapp/jsp/sample07.jsp (revision 2194)
+++ /FCKeditor.Java/tags/2.4/java-demo/src/main/webapp/jsp/sample07.jsp (revision 2194)
@@ -0,0 +1,70 @@
+
+<%@ page language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8" %>
+<%@ taglib uri="http://java.fckeditor.net" prefix="FCK" %>
+<%--
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ * - GNU General Public License Version 2 or later (the "GPL")
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * - Mozilla Public License Version 1.1 or later (the "MPL")
+ * http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ * @version: $Id$
+--%>
+
+
+
+ FCKeditor - JSP - Sample 7
+ In this sample the user can edit the complete page contents and header (from
+ <HTML> to </HTML>).
+
+
+
+
Index: /FCKeditor.Java/tags/2.4/java-demo/src/main/webapp/jsp/sampleposteddata.jsp
===================================================================
--- /FCKeditor.Java/tags/2.4/java-demo/src/main/webapp/jsp/sampleposteddata.jsp (revision 2194)
+++ /FCKeditor.Java/tags/2.4/java-demo/src/main/webapp/jsp/sampleposteddata.jsp (revision 2194)
@@ -0,0 +1,62 @@
+
+<%@ page language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8" import="java.util.Enumeration;"%>
+<%--
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ * - GNU General Public License Version 2 or later (the "GPL")
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * - Mozilla Public License Version 1.1 or later (the "MPL")
+ * http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ * @version: $Id$
+--%>
+
+
+
+ FCKeditor - Samples - Posted Data
+ This page lists all data posted by the form.
+
+
+
+
+
Index: /FCKeditor.Java/tags/2.4/java-demo/src/main/webapp/sample.css
===================================================================
--- /FCKeditor.Java/tags/2.4/java-demo/src/main/webapp/sample.css (revision 2194)
+++ /FCKeditor.Java/tags/2.4/java-demo/src/main/webapp/sample.css (revision 2194)
@@ -0,0 +1,15 @@
+body, td, input, select, textarea {
+ font-size: 12px;
+ font-family: Arial, Verdana, Sans-Serif;
+}
+
+h1 {
+ font-weight: bold;
+ font-size: 180%;
+ margin-bottom: 10px;
+}
+
+form {
+ margin: 0px 0px 0px 0px;
+ padding: 0px 0px 0px 0px;
+}
Index: /FCKeditor.Java/tags/2.4/java-demo/src/main/webapp/sampleslist.jsp
===================================================================
--- /FCKeditor.Java/tags/2.4/java-demo/src/main/webapp/sampleslist.jsp (revision 2194)
+++ /FCKeditor.Java/tags/2.4/java-demo/src/main/webapp/sampleslist.jsp (revision 2194)
@@ -0,0 +1,66 @@
+
+<%@ page language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8"%>
+<%--
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ * - GNU General Public License Version 2 or later (the "GPL")
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * - Mozilla Public License Version 1.1 or later (the "MPL")
+ * http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ * @version: $Id$
+--%>
+
+
+
+
+
+ <%
+ String parameter;
+ while(params.hasMoreElements()) {
+ parameter = params.nextElement();
+ %>
+ Field Name
+ Value
+
+
+ <%
+ }
+ %>
+ <%=parameter%>
+ <%=request.getParameter(parameter)%>
+
+
+
+
Index: /FCKeditor.Java/tags/2.4/java-demo/src/site/resources/css/site.css
===================================================================
--- /FCKeditor.Java/tags/2.4/java-demo/src/site/resources/css/site.css (revision 2194)
+++ /FCKeditor.Java/tags/2.4/java-demo/src/site/resources/css/site.css (revision 2194)
@@ -0,0 +1,1 @@
+@import url(../../css/site.css);
Index: /FCKeditor.Java/tags/2.4/pom.xml
===================================================================
--- /FCKeditor.Java/tags/2.4/pom.xml (revision 2194)
+++ /FCKeditor.Java/tags/2.4/pom.xml (revision 2194)
@@ -0,0 +1,322 @@
+
+
+ Please select the sample you want to view:
+
+
+ #foreach( $subitem in $item.items )
+ #menuItem( $subitem )
+ #end
+
+ #end
+ #end
+ $menu.name
+ #end
+ #if ( $menu.items && $menu.items.size() > 0 )
+
+ #foreach( $item in $menu.items )
+ #menuItem( $item )
+ #end
+
+ #end
+ #end
+#end
+
+#macro ( copyright )
+ #if ( $project )
+ #if ( ${project.organization} )
+ #set ( $period = "" )
+ #else
+ #set ( $period = "." )
+ #end
+ #set ( $currentYear = ${currentDate.year} + 1900 )
+ #if ( ${project.inceptionYear} && ( ${project.inceptionYear} != ${currentYear.toString()} ) )
+ ${project.inceptionYear}-${currentYear}${period}
+ #else
+ ${currentYear}${period}
+ #end
+
+ #if ( ${project.organization} )
+ #if ( ${project.organization.name} && ${project.organization.url} )
+ $project.organization.name.
+ #elseif ( ${project.organization.name} )
+ $project.organization.name.
+ #end
+ #end
+ #end
+#end
+
+#macro ( publishDate $position $publishDate $version )
+ #if ( $publishDate && $publishDate.format )
+ #set ( $format = $publishDate.format )
+ #else
+ #set ( $format = "yyyy-MM-dd" )
+ #end
+
+ $dateFormat.applyPattern( $format )
+
+ #set ( $dateToday = $dateFormat.format( $currentDate ) )
+
+ #if ( $publishDate && $publishDate.position )
+ #set ( $datePosition = $publishDate.position )
+ #else
+ #set ( $datePosition = "left" )
+ #end
+
+ #if ( $version )
+ #if ( $version.position )
+ #set ( $versionPosition = $version.position )
+ #else
+ #set ( $versionPosition = "left" )
+ #end
+ #end
+
+ #set ( $breadcrumbs = $decoration.body.breadcrumbs )
+ #set ( $links = $decoration.body.links )
+
+ #if ( $datePosition.equalsIgnoreCase( "right" ) && $links && $links.size() > 0 )
+ #set ( $prefix = " |" )
+ #else
+ #set ( $prefix = "" )
+ #end
+
+ #if ( $datePosition.equalsIgnoreCase( $position ) )
+ #if ( ( $datePosition.equalsIgnoreCase( "right" ) ) || ( $datePosition.equalsIgnoreCase( "bottom" ) ) )
+ $prefix $i18n.getString( "site-renderer", $locale, "template.lastpublished" ): $dateToday
+ #if ( $versionPosition.equalsIgnoreCase( $position ) )
+ | $i18n.getString( "site-renderer", $locale, "template.version" ): ${project.version}
+ #end
+ #elseif ( ( $datePosition.equalsIgnoreCase( "navigation-bottom" ) ) || ( $datePosition.equalsIgnoreCase( "navigation-top" ) ) )
+
+