Ticket #2034 (closed bug: fixed)

Opened 4 years ago

Last modified 4 years ago

OpenLayers.String.trim() fails to trim trailing whitespace on multi-line strings

Reported by: etdube Owned by: tschaub
Priority: minor Milestone: 2.8 Release
Component: BaseTypes Version: 2.7
Keywords: Cc:
State: Complete

Description

Test case:

var str = "chicken\nHead "; var trimmed = OpenLayers.String.trim(str); // trimmed = "chicken\nHead " ... wrong!

Attached patch replaces the trim regex with the 1st listed at  http://blog.stevenlevithan.com/archives/faster-trim-javascript , which is working for this case and should be efficient enough. Also updates tests/BaseTypes.html with a new testcase.

Attachments

openlayers_string_trim_fix.diff Download (1.2 KB) - added by etdube 4 years ago.
regex fix for OpenLayers.String.trim()

Change History

Changed 4 years ago by etdube

regex fix for OpenLayers.String.trim()

Changed 4 years ago by etdube

  • milestone changed from 2.9 Release to 2.8 Release

Bumped the milestone down to 2.8 Release, since the fix is simple and I'd like to use 2.8 for my app. If you don't have time to check this in for the release, feel free to bump it back to 2.9. Thanks.

Changed 4 years ago by tschaub

  • owner set to tschaub
  • status changed from new to assigned

Hey etdube, do we have a contributor license agreement from you?

Changed 4 years ago by tschaub

  • keywords string trim removed
  • status changed from assigned to closed
  • state set to Complete
  • resolution set to fixed

(In [9255]) Making OpenLayers.String.trim work for multiline strings. Thanks etdube for the patch. r=me (closes #2034)

Changed 4 years ago by tschaub

  • status changed from closed to reopened
  • state changed from Complete to Awaiting User Feedback
  • resolution fixed deleted

Please see HowToContribute for information on submitting a CLA. You can email a copy to the PSC while the paper one is in transit.

Changed 4 years ago by ryangroth5

I had a problem with this function screwing up Dojo. Dojo assumes that String.prototype.trim is native and the inferior OL version breaks their template system when OL is mixed with Dojo. They use the faster string trim that was cited so this will fix that problem too.

Changed 4 years ago by crschmidt

  • status changed from reopened to closed
  • state changed from Awaiting User Feedback to Complete
  • resolution set to fixed

ICLA Sent to PSC list.

Note: See TracTickets for help on using tickets.