Author: jleroux
Date: Sat Dec 30 05:11:43 2006 New Revision: 491221 URL: http://svn.apache.org/viewvc?view=rev&rev=491221 Log: Fix exception on checkout with apostrophe in address. Adapted from a Ray Barlow's patch (https://issues.apache.org/jira/browse/OFBIZ-248) Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilFormatOut.java Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java?view=diff&rev=491221&r1=491220&r2=491221 ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java Sat Dec 30 05:11:43 2006 @@ -295,20 +295,20 @@ String errMsg = null; if (this.cart != null && this.cart.size() > 0) { - this.cart.setShipBeforeDate(shipBefore); - this.cart.setShipAfterDate(shipAfter); + this.cart.setShipBeforeDate(shipBefore); + this.cart.setShipAfterDate(shipAfter); } else { - errMsg = UtilProperties.getMessage(resource,"checkhelper.no_items_in_cart", + errMsg = UtilProperties.getMessage(resource,"checkhelper.no_items_in_cart", (cart != null ? cart.getLocale() : Locale.getDefault())); - errorMessages.add(errMsg); + errorMessages.add(errMsg); } if (errorMessages.size() == 1) { - result = ServiceUtil.returnError(errorMessages.get(0).toString()); + result = ServiceUtil.returnError(errorMessages.get(0).toString()); } else if (errorMessages.size() > 0) { - result = ServiceUtil.returnError(errorMessages); + result = ServiceUtil.returnError(errorMessages); } else { - result = ServiceUtil.returnSuccess(); + result = ServiceUtil.returnSuccess(); } return result; } @@ -632,7 +632,7 @@ try { party = this.delegator.findByPrimaryKey("Party", UtilMisc.toMap("partyId", partyId)); } catch (GenericEntityException e) { - Debug.logWarning(e, UtilProperties.getMessage(resource_error,"OrderProblemsGettingPartyRecord", cart.getLocale()), module); + Debug.logWarning(e, UtilProperties.getMessage(resource_error,"OrderProblemsGettingPartyRecord", cart.getLocale()), module); party = null; } @@ -670,7 +670,7 @@ this.delegator.storeAll(toBeStored); } catch (GenericEntityException e) { // not a fatal error; so just print a message - Debug.logWarning(e, UtilProperties.getMessage(resource_error,"OrderProblemsStoringOrderEmailContactInformation", cart.getLocale()), module); + Debug.logWarning(e, UtilProperties.getMessage(resource_error,"OrderProblemsStoringOrderEmailContactInformation", cart.getLocale()), module); } } @@ -962,7 +962,7 @@ } } else { // should never happen - return ServiceUtil.returnError(UtilProperties.getMessage(resource_error,"OrderPleaseContactCustomerService;PaymentReturnCodeUnknown.", (cart != null ? cart.getLocale() : Locale.getDefault()))); + return ServiceUtil.returnError(UtilProperties.getMessage(resource_error,"OrderPleaseContactCustomerService;PaymentReturnCodeUnknown.", (cart != null ? cart.getLocale() : Locale.getDefault()))); } } else { // result returned null == service failed @@ -1091,14 +1091,15 @@ } public Map checkOrderBlacklist(GenericValue userLogin) { - if (cart == null) { + if (cart == null) { return ServiceUtil.returnSuccess("success"); - } + } GenericValue shippingAddressObj = this.cart.getShippingAddress(); - if (shippingAddressObj == null) { + if (shippingAddressObj == null) { return ServiceUtil.returnSuccess("success"); - } + } String shippingAddress = UtilFormatOut.checkNull(shippingAddressObj.getString("address1")).toUpperCase(); + shippingAddress = UtilFormatOut.makeSqlSafe(shippingAddress); List exprs = UtilMisc.toList(new EntityExpr( new EntityExpr(new EntityFunction.UPPER(new EntityFieldValue("blacklistString")), EntityOperator.EQUALS, new EntityFunction.UPPER(shippingAddress)), EntityOperator.AND, new EntityExpr("orderBlacklistTypeId", EntityOperator.EQUALS, "BLACKLIST_ADDRESS"))); @@ -1128,6 +1129,7 @@ } if (billingAddress != null) { String address = UtilFormatOut.checkNull(billingAddress.getString("address1").toUpperCase()); + address = UtilFormatOut.makeSqlSafe(address); exprs.add(new EntityExpr( new EntityExpr(new EntityFunction.UPPER(new EntityFieldValue("blacklistString")), EntityOperator.EQUALS, new EntityFunction.UPPER(address)), EntityOperator.AND, new EntityExpr("orderBlacklistTypeId", EntityOperator.EQUALS, "BLACKLIST_ADDRESS"))); @@ -1147,7 +1149,7 @@ } if (blacklistFound != null && blacklistFound.size() > 0) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource_error,"OrderFailed", (cart != null ? cart.getLocale() : Locale.getDefault()))); + return ServiceUtil.returnError(UtilProperties.getMessage(resource_error,"OrderFailed", (cart != null ? cart.getLocale() : Locale.getDefault()))); } else { return ServiceUtil.returnSuccess("success"); } Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilFormatOut.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilFormatOut.java?view=diff&rev=491221&r1=491220&r2=491221 ============================================================================== --- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilFormatOut.java (original) +++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilFormatOut.java Sat Dec 30 05:11:43 2006 @@ -491,4 +491,7 @@ return newString; } } + public static String makeSqlSafe(String unsafeString) { + return unsafeString.replaceAll("'","''"); + } } |
Free forum by Nabble | Edit this page |