Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

rhbz748727 Remove server-side Content-Type charset validation in favo…

…ur of client-side
  • Loading branch information...
commit c16ae7af44c5e10203a1fc7f2b9615cd784dcf6f 1 parent eaae695
Sean Flanigan seanf authored
44 server/zanata-war/src/main/java/org/zanata/rest/service/ResourceUtils.java
View
@@ -25,6 +25,7 @@
import javax.ws.rs.core.Response.Status;
import org.apache.commons.lang.StringUtils;
+import org.fedorahosted.tennera.jgettext.HeaderFields;
import org.jboss.seam.Component;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.AutoCreate;
@@ -75,27 +76,20 @@
* Newline character used for multi-line comments
*/
private static final char NEWLINE = '\n';
-
private static final String ZANATA_GENERATOR_PREFIX = "Zanata";
-
private static final String ZANATA_TAG = "#zanata";
-
private static final String PO_DATE_FORMAT = "yyyy-MM-dd hh:mmZ";
-
- private static final String[] PO_VALID_CONTENT_TYPES = {"charset=UTF-8", "charset=UTF8", "charset=ASCII", "charset=CHARSET"};
-
private static final String PO_DEFAULT_CONTENT_TYPE = "text/plain; charset=UTF-8";
-
/**
* PO Header entries
*/
private static final String LAST_TRANSLATOR_HDR = "Last-Translator";
- private static final String PO_REVISION_DATE_HDR = "PO-Revision-Date";
- private static final String LANGUAGE_TEAM_HDR = "Language-Team";
+ private static final String PO_REVISION_DATE_HDR = HeaderFields.KEY_PoRevisionDate;
+ private static final String LANGUAGE_TEAM_HDR = HeaderFields.KEY_LanguageTeam;
private static final String X_GENERATOR_HDR = "X-Generator";
- private static final String LANGUAGE_HDR = "Language";
- private static final String CONTENT_TYPE_HDR = "Content-Type";
+ private static final String LANGUAGE_HDR = HeaderFields.KEY_Language;
+ private static final String CONTENT_TYPE_HDR = HeaderFields.KEY_ContentType;
private static final String PLURAL_FORMS_HDR = "Plural-Forms";
private static final Log log = Logging.getLog(ResourceUtils.class);
@@ -1175,32 +1169,4 @@ public void transferToTranslationsResource(TranslationsResource transRes, HDocum
}
}
- public boolean validateResourceEncoding(Resource res)
- {
- PoHeader poHeader = res.getExtensions(true).findByType(PoHeader.class);
- if( poHeader != null )
- {
- for( HeaderEntry entry : poHeader.getEntries() )
- {
- if( entry.getKey().equalsIgnoreCase( CONTENT_TYPE_HDR ) )
- {
- for( String acceptedContentType : PO_VALID_CONTENT_TYPES )
- {
- // Case-insensitive check
- if( entry.getValue().toLowerCase().contains( acceptedContentType.toLowerCase() ) )
- {
- return true;
- }
- }
- }
- }
-
- return false;
- }
- else
- {
- return true;
- }
- }
-
}
9 server/zanata-war/src/main/java/org/zanata/rest/service/TranslationResourcesService.java
View
@@ -409,7 +409,6 @@ public Response putResource(@PathParam("id") String idNoSlash, Resource resource
validateExtensions();
log.debug("resource details: {0}", resource);
- boolean validResourceEnc = this.resourceUtils.validateResourceEncoding(resource);
HDocument document = documentDAO.getByDocId(hProjectIteration, id);
HLocale hLocale = validateSourceLocale(resource.getLang());
@@ -458,7 +457,6 @@ else if (document.isObsolete())
changed |= resourceUtils.transferFromResource(resource, document, extensions, hLocale, nextDocRev);
-
if (changed)
{
document = documentDAO.makePersistent(document);
@@ -466,20 +464,13 @@ else if (document.isObsolete())
etag = eTagUtils.generateETagForDocument(hProjectIteration, id, extensions);
}
-
if (copytrans && nextDocRev == 1)
{
copyClosestEquivalentTranslation(document.getId(), resource.getName(), projectSlug, iterationSlug);
}
- if( !validResourceEnc )
- {
- response.entity("warning: potentially incompatible character encoding.");
- }
-
log.debug("put resource successfully");
return response.tag(etag).build();
-
}
@Override
Please sign in to comment.
Something went wrong with that request. Please try again.